ImplicitActivity.java
Dosyayı İndir
package com.godoro.androidnavigations;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.View;
import android.widget.EditText;
public class ImplicitActivity extends Activity {
private EditText siteAddressEdit;
private EditText phoneNumberEdit;
private EditText mapLongitudeEdit;
private EditText mapLatitudeEdit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_implicit);
siteAddressEdit = (EditText) findViewById(R.id.siteAddressEdit);
siteAddressEdit.setText("http://www.godoro.com");
phoneNumberEdit = (EditText) findViewById(R.id.phoneNumberEdit);
phoneNumberEdit.setText("tel:(+90)5335612435");
mapLongitudeEdit = (EditText) findViewById(R.id.mapLongitudeEdit);
mapLongitudeEdit.setText("28.58");
mapLatitudeEdit = (EditText) findViewById(R.id.mapLatitudeEdit);
mapLatitudeEdit.setText("41.01");
}
public void onClickGoToSite(View view) {
String address = siteAddressEdit.getText().toString();
Uri uri = Uri.parse(address);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
public void onClickOpenPhone(View view) {
String phoneNumber = phoneNumberEdit.getText().toString();
Uri uri = Uri.parse(phoneNumber);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
public void onClickCallPhone(View view) {
String phoneNumber = phoneNumberEdit.getText().toString();
Uri uri = Uri.parse(phoneNumber);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(intent);
}
public void onClickOpenMap(View view){
String longitude=mapLongitudeEdit.getText().toString();
String latitude=mapLatitudeEdit.getText().toString();
String mapAddres=String.format("geo:%s,%s",longitude,latitude);
//String mapAddres=String.format("geo:%s,%s?z=19",longitude,latitude);
//String mapAddres="geo:0,0?q=query";
Uri uri= Uri.parse(mapAddres);
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);
}
public void onClickOpenContacts(View view){
String contactAddres="content://contacts/people/";
//String contactAddres="content://contacts/people/1";
Uri uri= Uri.parse(contactAddres);
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);
}
}
Dosyayı İndir