Example usage for android.content Intent FILL_IN_ACTION

List of usage examples for android.content Intent FILL_IN_ACTION

Introduction

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

Prototype

int FILL_IN_ACTION

To view the source code for android.content Intent FILL_IN_ACTION.

Click Source Link

Document

Use with #fillIn to allow the current action value to be overwritten, even if it is already set.

Usage

From source file:com.rampo.updatechecker.notice.Notification.java

public static void show(Context context, Store store, int notificationIconResId) {
    android.app.Notification notification;
    Intent myIntent = new Intent(Intent.ACTION_VIEW,
            Uri.parse(UpdateChecker.ROOT_PLAY_STORE_DEVICE + context.getPackageName()));
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, myIntent, Intent.FILL_IN_ACTION);
    String appName = null;/*from   w ww.j av  a 2 s .  c  o  m*/
    try {
        appName = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0)
                .loadLabel(context.getPackageManager()).toString();
    } catch (PackageManager.NameNotFoundException ignored) {
    }
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setTicker(context.getString(R.string.newUpdateAvailable)).setContentTitle(appName)
            .setContentText(context.getString(R.string.newUpdateAvailable)).setContentIntent(pendingIntent)
            .build();

    if (notificationIconResId == 0) {
        if (store == Store.GOOGLE_PLAY) {
            builder.setSmallIcon(R.drawable.ic_stat_play_store);
        } else if (store == Store.AMAZON) {
            builder.setSmallIcon(R.drawable.ic_stat_amazon);
        }
    } else {
        builder.setSmallIcon(notificationIconResId);
    }
    notification = builder.build();
    notification.flags = android.app.Notification.FLAG_AUTO_CANCEL;
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notification);
}