0% found this document useful (0 votes)
20 views4 pages

Zoom in PRG

The document describes how to implement zoom functionality on an image by using gestures to scale the image. It includes XML layouts to display the image and code to handle the scaling gestures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Zoom in PRG

The document describes how to implement zoom functionality on an image by using gestures to scale the image. It includes XML layouts to display the image and code to handle the scaling gestures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Zoom IN PRG

<?xml version="1.0" encoding="utf-8"?> import android.graphics.Matrix;


<RelativeLayout import android.os.Bundle;
xmlns:android="http://schemas.android.com/apk/res/an import
droid" androidx.appcompat.app.AppCompatActivity;
xmlns:tools="http://schemas.android.com/tools" import android.view.MotionEvent;
android:layout_width="match_parent" import android.view.ScaleGestureDetector;
android:layout_height="match_parent" import android.view.View;
tools:context=".MainActivity"> import android.widget.ImageView;

<ImageView public class MainActivity extends


android:id="@+id/imageView" AppCompatActivity {
android:layout_width="match_parent" private ImageView imageView;
android:layout_height="match_parent" private Matrix matrix = new Matrix();
android:scaleType="matrix" private float scale = 1f;
android:src="@drawable/your_image" /> private ScaleGestureDetector
scaleGestureDetector;
</RelativeLayout> @Override
protected void onCreate(Bundle
zoom_in.xml savedInstanceState) {
super.onCreate(savedInstanceState);
<vector setContentView(R.layout.activity_main);
xmlns:android="http://schemas.android.com/apk/res/an imageView =
droid" findViewById(R.id.imageView);
android:width="18dp" scaleGestureDetector = new
android:height="18dp" ScaleGestureDetector(this, new ScaleListener());
android:viewportWidth="24" imageView.setOnTouchListener(new
android:viewportHeight="24"> View.OnTouchListener() {
<path @Override
android:fillColor="#FF000000" public boolean onTouch(View v,
android:pathData="M13.5,9.5l2-2V7h0.5v1.5l2,2- MotionEvent event) {
2,2v1.5h-0.5l-2-2-2,2V14h-0.5V12.5l-2-2 2-2V7h0.5z"/>
</vector> scaleGestureDetector.onTouchEvent(event);
return true;}});}
private class ScaleListener extends
ScaleGestureDetector.SimpleOnScaleGestureLis
tener {
@Override
public boolean
onScale(ScaleGestureDetector detector) {
scale *= detector.getScaleFactor();
scale = Math.max(0.1f, Math.min(scale,
5.0f));
matrix.setScale(scale, scale);
imageView.setImageMatrix(matrix);
return true;}}}
Google Map

<?xml version="1.0" encoding="utf-8"?> import …


<RelativeLayout public class MainActivity extends
xmlns:android="http://schemas.android.com/ap AppCompatActivity implements
k/res/android" OnMapReadyCallback {

xmlns:tools="http://schemas.android.com/tools @Override
" protected void onCreate(Bundle
android:layout_width="match_parent" savedInstanceState) {
android:layout_height="match_parent" super.onCreate(savedInstanceState);
tools:context=".MainActivity"> setContentView(R.layout.activity_main);

<fragment SupportMapFragment mapFragment =


android:id="@+id/map" (SupportMapFragment)
getSupportFragmentManager()
android:name="com.google.android.gms.maps. .findFragmentById(R.id.map);
SupportMapFragment" mapFragment.getMapAsync(this);
android:layout_width="match_parent" }
android:layout_height="match_parent" />
@Override
</RelativeLayout> public void onMapReady(GoogleMap
googleMap) {
LatLng sydney = new LatLng(-34, 151);
googleMap.addMarker(new
MarkerOptions().position(sydney).title("Marker
in Sydney"));

googleMap.moveCamera(CameraUpdateFactor
y.newLatLng(sydney));
}
}
SMS
<?xml version="1.0" encoding="utf-8"?> @Override
<RelativeLayout public void onClick(View v) {
xmlns:android="http://schemas.android.com/apk/res/a sendMessage();}});
ndroid" IntentFilter intentFilter = new IntentFilter();
xmlns:tools="http://schemas.android.com/tools" intentFilter.addAction("android.provider.Telephony.SMS_REC
android:layout_width="match_parent" EIVED");
android:layout_height="match_parent" registerReceiver(smsReceiver, intentFilter);
tools:context=".MainActivity"> }
private void sendMessage() {
<EditText String phoneNumber =
android:id="@+id/editTextPhone" editTextPhone.getText().toString();
android:layout_width="match_parent" String message = editTextMessage.getText().toString();
android:layout_height="wrap_content"
android:hint="Enter phone number"/> SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber, null,
<EditText message, null, null);
android:id="@+id/editTextMessage" }
android:layout_width="match_parent" private final BroadcastReceiver smsReceiver = new
android:layout_height="wrap_content" BroadcastReceiver() {
android:layout_below="@id/editTextPhone" @Override
android:hint="Enter message"/> public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
<Button if (bundle != null) {
android:id="@+id/buttonSend" Object[] pdus = (Object[]) bundle.get("pdus");
android:layout_width="wrap_content" if (pdus != null) {
android:layout_height="wrap_content" for (Object pdu : pdus) {
android:layout_below="@id/editTextMessage" SmsMessage smsMessage =
android:text="Send"/> SmsMessage.createFromPdu((byte[]) pdu);
String sender =
<TextView smsMessage.getOriginatingAddress();
android:id="@+id/textView" String message =
android:layout_width="wrap_content" smsMessage.getMessageBody();
android:layout_height="wrap_content" textView.setText("SMS Received\nFrom: " +
android:layout_below="@id/buttonSend" sender + "\nMessage: " + message);
android:layout_marginTop="20dp"/> }
</RelativeLayout> }
}
Import… }
public class MainActivity extends AppCompatActivity { };
private static final int SMS_PERMISSION_CODE = 100;
private EditText editTextPhone, editTextMessage; @Override
private Button buttonSend; protected void onDestroy() {
private TextView textView; super.onDestroy();
@Override // Unregister receiver
protected void onCreate(Bundle savedInstanceState) { unregisterReceiver(smsReceiver);
super.onCreate(savedInstanceState); }
setContentView(R.layout.activity_main); }
editTextPhone = findViewById(R.id.editTextPhone);
editTextMessage =
findViewById(R.id.editTextMessage);
buttonSend = findViewById(R.id.buttonSend);
textView = findViewById(R.id.textView);
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.SEND_SMS) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new
String[]{Manifest.permission.SEND_SMS},
SMS_PERMISSION_CODE);}
buttonSend.setOnClickListener(new
View.OnClickListener() {
List Sensor Types supported by Android System
 Accelerometer
 Gyroscope
 Magnetometer (Compass)
 Proximity Sensor.
 Ambient Light Sensor

Define Geocoding and Reverse Geocoding


Geocoding:
Geocoding is the process of converting a human-readable address (like a street
address) into geographic coordinates (latitude and longitude). This process
allows you to identify the precise location of a place on the Earth's surface.
Reverse Geocoding:
Reverse Geocoding is the opposite process of geocoding. It involves converting
geographic coordinates (latitude and longitude) into a human-readable address
or location description. With reverse geocoding, you can determine the
approximate address or place name associated with a set of coordinates.

You might also like