Translate

Indonesian English French German Spain Italian Russian Portuguese Japanese Dutch Arabic Chinese Simplified

Intents:Dial and Call

Thursday, July 15, 2010


Intent is used to call the activity outside of the application has been made.
Intents is the main part of the application of activities, services, and broadcast receivers are activated via a message. Intents to serve a mechanism to pass messages between
applications or within the application itself.
Intents can also be used


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.net.Uri;
public class IntentsDial extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent DialIntent = new
Intent(Intent.ACTION_DIAL,Uri.parse("tel:0298322550"));
/** Finally start the Activity */
startActivity(DialIntent);
}
}





Calls can also be done immediately


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.net.Uri;
public class IntentsDial extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent CallIntent = new
Intent(Intent.ACTION_CALL,Uri.parse("tel:0298322550"));
/** Finally start the Activity */
try{startActivity(CallIntent);}
catch(Exception e)
{
Log.d("CallIntent",e.toString());
}
}
}

Do not forget to add permissions on AndroidManifest.xml.



0 comment:

Post a Comment

 
Theme by New wp themes | Bloggerized by Dhampire