1. New Share.xml Layout file
<?xml version= "1.0" encoding= "Utf-8"?><linearlayout xmlns:android="Http://schemas.android.com/apk/res/android" Android:layout_width="Fill_parent"android:layout_height="Fill_parent" Android:orientation="vertical" > <buttonandroid:id="@+id/share"android:layout_width="fill_parent "android:layout_height="wrap_content "android:text=" Share " /> </linearlayout>
2. New Shareactivity
/** * Shareactivity.java * All rights reserved (C) 2015 * created: Cuiran 2015-7-29 * * Packagecom.share.activity;Importandroid.app.Activity;ImportAndroid.content.Intent;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.widget.Button;/** * Todo * @author Cuiran * @version Todo * * Public class shareactivity extends Activity { @Override protected void onCreate(Bundle savedinstancestate) {//TODO auto-generated method stub Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.share); Button share= (button) This. Findviewbyid (R.id.share); Share.setonclicklistener (NewView.onclicklistener () {@Override Public void OnClick(View v) {Intent intent=NewIntent (Intent.action_send); Intent.settype ("image/*"); Intent.putextra (Intent.extra_subject,"Share"); Intent.putextra (Intent.extra_text,"I have successfully share my message through my app (by Dengao)"); Intent.setflags (Intent.flag_activity_new_task); StartActivity (Intent.createchooser (Intent, GetTitle ())); } }); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android for sharing features