Example usage for android.content Intent setAction

List of usage examples for android.content Intent setAction

Introduction

In this page you can find the example usage for android.content Intent setAction.

Prototype

public @NonNull Intent setAction(@Nullable String action) 

Source Link

Document

Set the general action to be performed.

Usage

From source file:Main.java

/**
 * Launch Application Setting to grant permission.
 *//*from   ww  w  .ja v a  2 s.  c o m*/
public static void launchPermissionSettings(Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
    activity.startActivity(intent);
}

From source file:Main.java

/**
 * Install apk//from w  w w  . j  av a 2  s  .  c o m
 */
public static void installApk(Context context, File file) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void goDial(Context context, String dial_number) {
    Intent phonepassIntent = new Intent();
    phonepassIntent.setAction(Intent.ACTION_DIAL);
    phonepassIntent.setData(Uri.parse("tel:" + dial_number));
    context.startActivity(phonepassIntent);
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static void startAlarmService(Context context, int triggerAtMillis, Class<?> cls, String action) {
    Intent intent = new Intent(context, cls);
    intent.setAction(action);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    startAlarmIntent(context, triggerAtMillis, pendingIntent);
}

From source file:Main.java

public static void installApk(Context context, File apkfile) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.setType("application/vnd.android.package-archive");
    intent.setData(Uri.fromFile(apkfile));
    intent.setDataAndType(Uri.fromFile(apkfile), "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*from  w ww.  j av  a  2 s.  co  m*/
}

From source file:Main.java

/**
 * Checks if there is any of the CFI apps installed on the device supports PBBA payment.
 *
 * @param context application context//from   w  ww.ja  v a2 s  .  c  om
 * @return true if available
 */
public static boolean isZappCFIAppAvailable(@NonNull final Context context) {
    final Intent zappIntent = new Intent();
    zappIntent.setAction(Intent.ACTION_VIEW);
    zappIntent.setData(new Uri.Builder().scheme(ZAPP_SCHEME).build());
    final ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(zappIntent,
            PackageManager.MATCH_DEFAULT_ONLY);
    return resolveInfo != null;
}

From source file:Main.java

public static void startDataCheck(Activity callingActivity) {
    Log.d(TAG, "launching speech check");
    Intent checkIntent = new Intent();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    callingActivity.startActivityForResult(checkIntent, SPEECH_DATA_CHECK_CODE);
}

From source file:Main.java

public static void sendBrodcast(Context context, String action, String content) {
    if (TextUtils.isEmpty(action) || context == null) {
        return;//from ww w .j a va 2s .c  om
    }
    Intent intent = new Intent();
    intent.setAction(action);
    intent.putExtra("extra", content);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void sendBrodcast(Context context, String action, Bundle bundle) {
    if (TextUtils.isEmpty(action) || context == null) {
        return;/*from w w w  . jav  a 2s. co  m*/
    }
    Intent intent = new Intent();
    intent.setAction(action);
    intent.putExtra("extra", bundle);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void callSysShare(Context context, String chooserTitle, String shareTitle, String shareText,
        String mime, Uri uri) {/*ww w . j av a2  s  .  c o  m*/
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(Intent.EXTRA_TEXT, shareText);
    intent.putExtra(Intent.EXTRA_SUBJECT, shareTitle);
    intent.setType(mime);
    if (uri != null) {
        intent.putExtra(Intent.EXTRA_STREAM, uri);
    }
    context.startActivity(Intent.createChooser(intent, chooserTitle));
}