Example usage for android.content Intent getAction

List of usage examples for android.content Intent getAction

Introduction

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

Prototype

public @Nullable String getAction() 

Source Link

Document

Retrieve the general action to be performed, such as #ACTION_VIEW .

Usage

From source file:Main.java

public static boolean isSplashOpenedOverNavigationActivity(final Activity act, final Intent intent) {
    return intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_MAIN)
            && !act.isTaskRoot() && intent.hasCategory(Intent.CATEGORY_LAUNCHER);
}

From source file:Main.java

/**
 * Returns import source uri based on the Intent.
 *///from   w ww  .  j a  v a 2s.  co  m
static Uri getImportUri(Intent intent) {
    String action = intent.getAction();
    if (Intent.ACTION_SEND.equals(action)) {
        return intent.getParcelableExtra(Intent.EXTRA_STREAM);
    }
    if (Intent.ACTION_VIEW.equals(action)) {
        return intent.getData();
    }
    return null;
}

From source file:Main.java

public static String getAction(Intent intent) {
    if (intent != null) {
        return intent.getAction();
    }/* w ww .j  a v  a  2s. c o m*/
    return null;
}

From source file:Main.java

public static void dumpIntent(Intent intent) {
    System.out.println("action: " + intent.getAction());
    System.out.println("data: " + intent.getData());
    System.out.println("extras:");
    Bundle bundle = intent.getExtras();//w ww  .j a  v  a 2s . c o m
    for (String key : bundle.keySet()) {
        Object object = bundle.get(key);
        System.out.println(key + "->" + object + "(" + object.getClass().getName() + ")");
    }
}

From source file:Main.java

/**
 * Start System Activity./*from w w w .  j a v  a 2  s.  c  om*/
 * Display Toast with the message if activity not available
 * @param activity- {@link Activity} instance
 * @param action - String representing {@link Settings}
 * @param altToastMessage - Message to be displayed in Toast if {@link Activity} not available
 */
public static void startSystemActivity(Activity activity, String action, String altToastMessage) {
    Intent locationIntent = new Intent(action);
    if (locationIntent.getAction() != null) {
        activity.startActivity(locationIntent);
    } else {
        if (altToastMessage != null) {
            showToast(activity, altToastMessage);
        }
    }
}

From source file:Main.java

/**
 * @param message to open the camera./*  www  .j  av a 2s.c  om*/
 *  
 *  
 */
static void displayImage(Context context, String message) {
    Intent intent = new Intent(DISPLAY_IMAGE_ACTION);

    intent.getAction();
    context.sendBroadcast(intent);
}

From source file:Main.java

public static String toString(Intent intent) {
    StringBuilder sb = new StringBuilder();
    sb.append(intent.getAction()).append(" ");

    Bundle bundle = intent.getExtras();//from   w  w w .  ja v a2  s  .co  m
    if (bundle != null) {
        Set<String> sets = bundle.keySet();
        for (String key : sets) {
            if (bundle.get(key) instanceof Integer) {
                sb.append(key).append(":").append(bundle.getInt(key)).append("\n");
            } else if (bundle.get(key) instanceof ArrayList) {
                sb.append(key).append(":").append(Arrays.toString(bundle.getIntegerArrayList(key).toArray()))
                        .append("\n");
            } else if (bundle.get(key) instanceof Parcelable) {
                sb.append(key).append(":").append(bundle.getParcelable(key).toString()).append("\n");
            } else {
                sb.append(key).append(":").append(bundle.getString(key)).append("\n");
            }
        }

    }

    return sb.toString();
}

From source file:Main.java

/**
 * @param message to open the camera./*from   w w w  . j av  a2  s  .c  om*/
 *  
 *  
 */
static void openCamera(Context context, String message) {
    Intent intent = new Intent(CAMERA_OPEN_ACTION);
    // intent.putExtra(EXTRA_MESSAGE, message);
    intent.getAction();
    context.sendBroadcast(intent);
}

From source file:Main.java

static boolean checkForIntentWithAction(Activity activity, String action) {
    Intent intent = activity.getIntent();
    if (intent == null) {
        return false;
    }/* www  .ja v  a2  s  . c o m*/
    return TextUtils.equals(intent.getAction(), action);
}

From source file:Main.java

private static void appendIntent(StringBuilder sb, Intent intent) {
    if (intent != null) {
        String uri = intent.toUri(Intent.URI_INTENT_SCHEME);
        String action = intent.getAction();
        append(sb, "intent", action, uri);
    } else {//  w  w  w . j a va  2  s  .  com
        append(sb, (String) null);
    }
}