***
import android.net.Uri;
http://stackoverflow.com/questions/7545254/android-and-facebook-share-intent
http://stackoverflow.com/questions/3515198/share-text-on-facebook-from-android-app-via-action-send
final boolean isInstalled = appInstalledOrNot(packageName);
if (isInstalled) {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
waIntent.setPackage(packageName);
if (waIntent != null) {
if (!personalMsg.equalsIgnoreCase("")) {
//waIntent.putExtra(Intent.EXTRA_TEXT, "Hi");
waIntent.putExtra(Intent.EXTRA_TEXT, personalMsg + " \n \n" + getResources().getString(R.string.share_text) + " " + AppPrefs.getInstance(mContext).getOrgName().toString().toLowerCase() + " \n\n" + mShortURL);
} else {
waIntent.putExtra(Intent.EXTRA_TEXT, mShortURL + " \n\n" + getResources().getString(R.string.share_text) + AppPrefs.getInstance(mContext).getOrgName().toString().toLowerCase());
}
startActivity(Intent.createChooser(waIntent, "share with"));
}
} else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + packageName));
startActivity(intent);
}
}
private boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
boolean app_installed;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
} catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}
No comments:
Post a Comment