Dial Activity
Designing Part:
what what is considered the most reasonable thing for a particular URI.
Layout file: Main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<EditText android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:id="@+id/txtNo"
android:layout_toLeftOf="@+id/Dial_button">
</EditText>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignBaseline="@+id/editText1"
android:layout_alignBottom="@+id/editText1"
android:layout_alignParentRight="true"
android:text="Dial"
android:id="@+id/Dial_button">
</Button>
</RelativeLayout>
Coding Part:
package com.murali.Dial;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class DialActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText EDtxt=(EditText) findViewById(R.id.txtNo);
Button Dial=(Button) findViewById(R.id.Dial_button);
Dial.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String mNumber=EDtxt.getText().toString();
// This is Intent for Starting Dail Activity...........................
Intent dailintent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+mNumber));
startActivity(dailintent);
}
});
}
}
Explanation for javaCode:
ACTION_VIEW
tel:123 -- Display the phone dialer with the given number filled in. Note how the VIEW action does what what is considered the most reasonable thing for a particular URI.
Comments
Post a Comment