This repository was archived by the owner on Feb 25, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
src/com/example/javabutton Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 1+ <menu xmlns : android =" http://schemas.android.com/apk/res/android" >
2+ <item
3+ android:id=" @+id/menu_item_share"
4+ android:showAsAction=" ifRoom"
5+ android:title=" @string/action_share"
6+ android:actionProviderClass=" android.widget.ShareActionProvider" />
7+ <item
8+ android : id =" @+id/action_settings"
9+ android : orderInCategory =" 100"
10+ android : showAsAction =" ifRoom"
11+ android : title =" @string/action_settings"
12+ android : icon =" @drawable/action_settings" />
13+ </menu >
Original file line number Diff line number Diff line change 11<menu xmlns : android =" http://schemas.android.com/apk/res/android" >
2- <item
3- android:id=" @+id/menu_item_share"
4- android:showAsAction=" ifRoom"
5- android:title=" @string/action_share"
6- android:actionProviderClass=" android.widget.ShareActionProvider" />
72 <item
83 android : id =" @+id/action_settings"
94 android : orderInCategory =" 100"
Original file line number Diff line number Diff line change 44import android .hardware .SensorEvent ;
55import android .hardware .SensorEventListener ;
66import android .hardware .SensorManager ;
7+ import android .os .Build ;
78import android .os .Bundle ;
89import android .preference .PreferenceManager ;
10+ import android .annotation .TargetApi ;
911import android .app .Activity ;
1012import android .content .Intent ;
1113import android .content .SharedPreferences ;
@@ -112,7 +114,14 @@ protected void onDestroy() {
112114 public boolean onCreateOptionsMenu (Menu menu ) {
113115 // Inflate the menu; this adds items to the action bar if it is present.
114116 getMenuInflater ().inflate (R .menu .main , menu );
117+ if (Build .VERSION .SDK_INT >=14 ) {
118+ setupShareAction (menu );
119+ }
120+ return true ;
121+ }
115122
123+ @ TargetApi (Build .VERSION_CODES .JELLY_BEAN )
124+ private boolean setupShareAction (Menu menu ) {
116125 MenuItem shareItem =menu .findItem (R .id .menu_item_share );
117126 ShareActionProvider sap =(ShareActionProvider )shareItem .getActionProvider ();
118127 if (sap !=null ) {
You can’t perform that action at this time.
0 commit comments