Android app code to make a phone call, turn on the phone sharing function and other implicit intentions

Source: Internet
Author: User
Tags comparison table

Android App Call:

Intent intent=new Intent (Intent.action_dial,uri.parse ("Tel:" +110));
StartActivity (Intent);
}

Android app opens phone book:

Intent Intent = new Intent (Intent.action_pick,contactscontract.contacts.content_uri);
StartActivity (Intent);

Android App SMS Sharing:

Intent sendintent = new Intent (Intent.action_view);
Sendintent.putextra ("Sms_body", "#短信分享 #");
Sendintent.settype ("vnd.android-dir/mms-sms");
StartActivity (sendintent);

To turn on your phone's sharing features:

Intent sendintent = new Intent (intent.action_ SEND);
//   Sendintent.settype ("image/png");//Picture
// file F = new file (environment.getexternalstoragedirectory () +"/pictures/2.png ");
// Uri u = uri.fromfile (f);
// Sendintent.putextra (intent.extra_stream, u);
  sendintent.settype ("Text/plain");//text
  Sendintent.putextra (Intent.extra_subject," #好友分享 # ");  

Send details of your own unsolicited join
Sendintent.putextra (Intent.extra_text, "I'm playing the app now, add it together.") Many other information see: http://www.xx.com ");
Sendintent.setflags (Intent.flag_activity_new_task);
StartActivity (Intent.createchooser (Sendintent, GetTitle ()));

Open the store for evaluation:

Uri uri=uri.parse ("Market://details?")

Id= "+ Activity.this.getPackageName ());
Intent intent=new Intent (Intent.action_view, URI);
Packagemanager pm = SettingActivity.this.getPackageManager ();
list<resolveinfo> list = pm.queryintentactivities (intent, 0);
if (List.size () ==0) {
Toast.maketext (settingactivity.this, "software store not Installed", Toast.length_short). Show ();
}else{
StartActivity (Intent);
}

To Create a desktop shortcut icon:
To send the broadcast intent, to create a shortcut icon
Intent Intent = new Intent ();
Intent.setaction ("Com.android.launcher.action.INSTALL_SHORTCUT");
Shortcut to include 3 important information 1, Name 2. Icon 3. What to Do
Intent.putextra (Intent.extra_shortcut_name, "Aberdeen mobile phone security defender");
Intent.putextra (Intent.extra_shortcut_icon, Bitmapfactory.decoderesource (Getresources (), R.drawable.ic_launcher) );
Desktop click on the icon corresponding to the intent.


Intent shortcutintent = new Intent ();
Shortcutintent.setaction ("Android.intent.action.MAIN");
Shortcutintent.addcategory ("Android.intent.category.LAUNCHER");
Shortcutintent.setclassname (Getpackagename (), "com.zaizai.safty.MainActivity");
Intent.putextra (Intent.extra_shortcut_intent, shortcutintent);
Sendbroadcast (Intent);

Need to add permission
Com.android.launcher.permission.INSTALL_SHORTCUT

MIME Type comparison table: Http://tool.oschina.net/commons http://blog.sina.com.cn/s/blog_446cc66b0100ublv.html

Android app code to make a phone call, turn on the phone sharing function and other implicit intentions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.