|
public class Var { |
|
|
|
public static void yKien(Context context,String email) { |
|
try { |
|
Intent emailIntent = new Intent(Intent.ACTION_SEND); |
|
String[] recipients = new String[]{email}; |
|
emailIntent.putExtra(Intent.EXTRA_EMAIL, recipients); |
|
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Góp ý về ứng dụng "); |
|
emailIntent.putExtra(Intent.EXTRA_TEXT, "Ý kiến:"); |
|
emailIntent.setType("plain/text"); |
|
final PackageManager pm = context.getPackageManager(); |
|
final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0); |
|
ResolveInfo best = null; |
|
for (final ResolveInfo info : matches) |
|
if (info.activityInfo.packageName.endsWith(".gm") || |
|
info.activityInfo.name.toLowerCase().contains("gmail")) best = info; |
|
if (best != null) |
|
emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name); |
|
context.startActivity(emailIntent); |
|
} catch (Exception e) { |
|
Toast.makeText(context, "Application not found", Toast.LENGTH_SHORT).show(); |
|
} |
|
} |
|
|
|
public static void shareFB(Context context,String url) { |
|
Intent intent = new Intent(Intent.ACTION_SEND); |
|
intent.putExtra(Intent.EXTRA_TEXT, url); |
|
intent.setType("text/plain"); |
|
|
|
List<ResolveInfo> matches = context.getPackageManager().queryIntentActivities(intent, 0); |
|
for (ResolveInfo info : matches) { |
|
if (info.activityInfo.packageName.toLowerCase().contains("facebook")) { |
|
intent.setPackage(info.activityInfo.packageName); |
|
} |
|
} |
|
|
|
context.startActivity(intent); |
|
} |
|
|
|
public static void rateApp(Context context) { |
|
Uri uri = Uri.parse("market://details?id=" + context.getPackageName()); |
|
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); |
|
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | |
|
Intent.FLAG_ACTIVITY_NEW_DOCUMENT | |
|
Intent.FLAG_ACTIVITY_MULTIPLE_TASK); |
|
try { |
|
context.startActivity(goToMarket); |
|
} catch (ActivityNotFoundException e) { |
|
context.startActivity(new Intent(Intent.ACTION_VIEW, |
|
Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName()))); |
|
} |
|
} |
|
} |