Switch ShareProvider implementation
parent
31c6171a9e
commit
969b83c818
|
@ -6,7 +6,7 @@
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="11"
|
android:minSdkVersion="14"
|
||||||
android:targetSdkVersion="19" />
|
android:targetSdkVersion="19" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
xmlns:support="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<item android:id="@+id/action_help"
|
<item android:id="@+id/action_help"
|
||||||
android:icon="@drawable/ic_action_help"
|
android:icon="@drawable/ic_action_help"
|
||||||
android:title="@string/action_help"
|
android:title="@string/action_help"
|
||||||
support:showAsAction="ifRoom" />
|
android:showAsAction="ifRoom" />
|
||||||
|
|
||||||
<!-- Share / will display always -->
|
<!-- Share / will display always -->
|
||||||
<item android:id="@+id/action_share"
|
<item android:id="@+id/action_share"
|
||||||
android:icon="@drawable/ic_action_share"
|
android:icon="@drawable/ic_action_share"
|
||||||
android:title="@string/action_share"
|
android:title="@string/action_share"
|
||||||
support:showAsAction="always"
|
android:showAsAction="always"
|
||||||
support:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
|
android:actionProviderClass="android.widget.ShareActionProvider" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.net.*;
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.net.*;
|
import android.net.*;
|
||||||
import android.support.v4.view.*;
|
import android.support.v4.view.*;
|
||||||
import android.support.v7.widget.ShareActionProvider;
|
import android.widget.ShareActionProvider;
|
||||||
|
|
||||||
public class MainActivity extends Activity implements Constants
|
public class MainActivity extends Activity implements Constants
|
||||||
{
|
{
|
||||||
|
@ -27,17 +27,16 @@ public class MainActivity extends Activity implements Constants
|
||||||
ArrayAdapter<String> adapter;
|
ArrayAdapter<String> adapter;
|
||||||
List<String> list= null;
|
List<String> list= null;
|
||||||
private ShareActionProvider mShare;
|
private ShareActionProvider mShare;
|
||||||
protected String dorkSelected = "";
|
protected String dorkSelected = "Nothing selected to share";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu, menu);
|
getMenuInflater().inflate(R.menu.menu, menu);
|
||||||
MenuItem shareItem = menu.findItem(R.id.action_share);
|
mShare = (ShareActionProvider)menu.findItem(R.id.action_share).getActionProvider();
|
||||||
mShare = (android.support.v7.widget.ShareActionProvider)MenuItemCompat.getActionProvider(shareItem);
|
return true;
|
||||||
mShare.setShareIntent(getShareItem());
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
|
@ -100,8 +99,8 @@ public class MainActivity extends Activity implements Constants
|
||||||
int pos, long arg3) {
|
int pos, long arg3) {
|
||||||
dorkSelected = list.get(pos).toString();
|
dorkSelected = list.get(pos).toString();
|
||||||
Intent inten = new Intent(Intent.ACTION_SEND);
|
Intent inten = new Intent(Intent.ACTION_SEND);
|
||||||
inten.putExtra(Intent.EXTRA_TEXT, dorkSelected);
|
|
||||||
inten.setType("text/plain");
|
inten.setType("text/plain");
|
||||||
|
inten.putExtra(Intent.EXTRA_TEXT, dorkSelected);
|
||||||
setShareIntent(inten);
|
setShareIntent(inten);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -142,10 +141,14 @@ public class MainActivity extends Activity implements Constants
|
||||||
ShowHelp sh = new ShowHelp(this);
|
ShowHelp sh = new ShowHelp(this);
|
||||||
sh.setTitle("About Google Dorks by CMB");
|
sh.setTitle("About Google Dorks by CMB");
|
||||||
sh.show();
|
sh.show();
|
||||||
return true;
|
break;
|
||||||
|
case R.id.action_share:
|
||||||
|
getShareItem();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
break;
|
||||||
}
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShareIntent(Intent shareIntent) {
|
private void setShareIntent(Intent shareIntent) {
|
||||||
|
@ -156,7 +159,9 @@ public class MainActivity extends Activity implements Constants
|
||||||
|
|
||||||
private Intent getShareItem() {
|
private Intent getShareItem() {
|
||||||
Intent inten = new Intent(Intent.ACTION_SEND);
|
Intent inten = new Intent(Intent.ACTION_SEND);
|
||||||
inten.setType("image/*");
|
inten.setType("text/plain");
|
||||||
|
inten.putExtra(Intent.EXTRA_TEXT, dorkSelected);
|
||||||
|
mShare.setShareIntent(inten);
|
||||||
return inten;
|
return inten;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue