List of usage examples for android.content.pm PackageManager getText
public abstract CharSequence getText(String packageName, @StringRes int resid, ApplicationInfo appInfo);
From source file:org.droid2droid.ui.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.main_fragment_menu, menu); // Share menu try {/*from ww w . j a va 2s. c o m*/ MenuItem item = menu.findItem(R.id.share); PackageManager pm = getPackageManager(); ApplicationInfo info = pm.getApplicationInfo(getPackageName(), 0); Intent shareIntent = new Intent(Intent.ACTION_SEND) .putExtra(Intent.EXTRA_SUBJECT, pm.getText(getPackageName(), info.labelRes, info)) .putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(info.sourceDir))) // .setType("application/vnd.android.package-archive"); .setType("*/*") // Android >3.x refuse to download apk // .setType("image/jpeg") ; ShareActionProvider shareActionProvider = (ShareActionProvider) item.getActionProvider(); shareActionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); shareActionProvider.setShareIntent(shareIntent); } catch (NameNotFoundException e) { // Ignore if (E) Log.e(TAG_INSTALL, "Impossible to share RemoteAndroid"); } return true; }