Example usage for android.app PendingIntent getCreatorPackage

List of usage examples for android.app PendingIntent getCreatorPackage

Introduction

In this page you can find the example usage for android.app PendingIntent getCreatorPackage.

Prototype

@Nullable
public String getCreatorPackage() 

Source Link

Document

Return the package name of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.

Usage

From source file:Main.java

/**
 * @see android.app.PendingIntent#getCreatorPackage()
 *///from   w w w  .j ava2 s .c  o m
@SuppressWarnings("deprecation")
public static String getCreatorPackage(PendingIntent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return intent.getCreatorPackage();
    } else {
        return intent.getTargetPackage();
    }
}

From source file:android.support.customtabs.browseractions.BrowserActionsIntent.java

/**
 * Get the package name of the creator application.
 * @param intent The {@link BrowserActionsIntent}.
 * @return The creator package name.// w ww . ja  va 2  s . c  o m
 */
@SuppressWarnings("deprecation")
public static String getCreatorPackageName(Intent intent) {
    PendingIntent pendingIntent = intent.getParcelableExtra(BrowserActionsIntent.EXTRA_APP_ID);
    if (pendingIntent != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            return pendingIntent.getCreatorPackage();
        } else {
            return pendingIntent.getTargetPackage();
        }
    }
    return null;
}