当前位置: 首页>>代码示例>>Java>>正文


Java PendingIntent.getActivity方法代码示例

本文整理汇总了Java中android.app.PendingIntent.getActivity方法的典型用法代码示例。如果您正苦于以下问题:Java PendingIntent.getActivity方法的具体用法?Java PendingIntent.getActivity怎么用?Java PendingIntent.getActivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.PendingIntent的用法示例。


在下文中一共展示了PendingIntent.getActivity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: installPackageInternal

import android.app.PendingIntent; //导入方法依赖的package包/类
@Override
protected void installPackageInternal(Uri localApkUri, Uri downloadUri) {

    Intent installIntent = new Intent(context, DefaultInstallerActivity.class);
    installIntent.setAction(DefaultInstallerActivity.ACTION_INSTALL_PACKAGE);
    installIntent.putExtra(Installer.EXTRA_DOWNLOAD_URI, downloadUri);
    installIntent.putExtra(Installer.EXTRA_APK, apk);
    installIntent.setData(localApkUri);

    PendingIntent installPendingIntent = PendingIntent.getActivity(
            context.getApplicationContext(),
            localApkUri.hashCode(),
            installIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_USER_INTERACTION,
            installPendingIntent);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:19,代码来源:DefaultInstaller.java

示例2: success

import android.app.PendingIntent; //导入方法依赖的package包/类
private void success(String path) {
    builder.setProgress(0, 0, false);
    builder.setContentText(getString(R.string.update_app_model_success));
    Intent i = installIntent(this, path);
    PendingIntent intent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(intent);
    builder.setDefaults(downloadSuccessNotificationFlag);
    Notification n = builder.build();
    n.contentIntent = intent;
    manager.notify(notifyId, n);
    sendLocalBroadcast(UPDATE_SUCCESS_STATUS, 100);
    if (updateProgressListener != null) {
        updateProgressListener.success();
    }
    startActivity(i);
    stopSelf();
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:18,代码来源:UpdateService.java

示例3: showNotification

import android.app.PendingIntent; //导入方法依赖的package包/类
/**
    * Show a notification while this service is running.
    */
private void showNotification() {
       // In this sample, we'll use the same text for the ticker and the expanded notification
       CharSequence text = getText(R.string.copilot_service_started);

       // Set the icon, scrolling text and timestamp
       Notification notification = new Notification(R.drawable.icon_copilot, text, System.currentTimeMillis());

       // The PendingIntent to launch our activity if the user selects this notification
       PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MCP.class), 0);

       // Set the info for the views that show in the notification panel.
       notification.setLatestEventInfo(this, getText(R.string.copilot_service), text, contentIntent);

       // Send the notification.
       // We use a layout id because it is a unique number.  We use it later to cancel.
       mNM.notify(R.string.copilot_service, notification);
   }
 
开发者ID:Nailim,项目名称:alreon,代码行数:21,代码来源:copilotService.java

示例4: closeNitify

import android.app.PendingIntent; //导入方法依赖的package包/类
/**
 * 关闭Nitify
 */
@SuppressWarnings({"unused", "deprecation"})
@TargetApi(16)
private void closeNitify() {
    nitify.flags = Notification.FLAG_AUTO_CANCEL;
    nitify.contentView = null;
    Intent intent = new Intent(mContext, MainActivity.class);
    // 告知已完成
    intent.putExtra("completed", "yes");
    // 更新参数,注意flags要使用FLAG_UPDATE_CURRENT
    PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0,
            intent, PendingIntent.FLAG_UPDATE_CURRENT);
    nitify = new Notification.Builder(mContext)
            .setAutoCancel(true)
            .setContentTitle("下载完成")
            .setContentText("文件已下载完毕")
            .setContentIntent(contentIntent)
            .setSmallIcon(R.mipmap.logo)
            .setWhen(System.currentTimeMillis())
            .build();
    mNotificationManager.notify(notifyId, nitify);

}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:26,代码来源:UpdateManager.java

示例5: createNotification

import android.app.PendingIntent; //导入方法依赖的package包/类
/**
 * 通知を表示します。
 */
private Notification createNotification() {
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(R.mipmap.ic_launcher);
    builder.setContentTitle(getString(R.string.mail_content_title));
    builder.setContentText(getString(R.string.content_text));
    builder.setOngoing(true);
    builder.setPriority(NotificationCompat.PRIORITY_MIN);
    builder.setCategory(NotificationCompat.CATEGORY_SERVICE);

    // PendingIntent作成
    final Intent notifyIntent = new Intent(this, DeleteActionActivity.class);
    PendingIntent notifyPendingIntent = PendingIntent.getActivity(this, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(notifyPendingIntent);

    return builder.build();
}
 
开发者ID:cheenid,项目名称:FLFloatingButton,代码行数:21,代码来源:CustomFloatingViewService.java

示例6: createAuthIntent

import android.app.PendingIntent; //导入方法依赖的package包/类
public static PendingIntent createAuthIntent(Context context, String shareUri) {
  Intent authIntent = new Intent();
  authIntent.setComponent(new ComponentName(
          context.getPackageName(),
          AuthActivity.class.getName()));
  authIntent.putExtra(SHARE_URI_KEY, shareUri);

  return PendingIntent.getActivity(
          context, 0, authIntent, PendingIntent.FLAG_UPDATE_CURRENT);
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:11,代码来源:AuthActivity.java

示例7: addNotification

import android.app.PendingIntent; //导入方法依赖的package包/类
private void addNotification(String title, String message) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_notifications_black_24dp)
            .setContentTitle(title)
            .setContentText(message);

    Intent intent = new Intent(this, MainActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(contentIntent);

    // Add as notification
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(0, builder.build());
}
 
开发者ID:Jack-Q,项目名称:messenger,代码行数:16,代码来源:MainService.java

示例8: showNotification

import android.app.PendingIntent; //导入方法依赖的package包/类
public static void showNotification(Context context, boolean isPaused) {
    if (!SPUtil.isNotificationEnabled(context)) {
        return;
    }

    PendingIntent activityIntent = PendingIntent.getActivity(context, 0, new Intent(context, SettingsActivity.class), 0);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))
            .setSmallIcon(R.drawable.ic_notification)
            .setColor(context.getResources().getColor(R.color.colorPrimary))
            .setContentTitle(context.getString(R.string.app_is_running, context.getString(R.string.app_name)))
            .setContentText(context.getString(R.string.action_to_settings))
            .setContentIntent(activityIntent)
            .setOngoing(!isPaused);

    if (isPaused) {
        builder.addAction(R.drawable.ic_action_resume, context.getString(R.string.action_to_resume),
                getPendingIntent(context, ACTION_RESUME));
    } else {
        builder.addAction(R.drawable.ic_action_pause, context.getString(R.string.action_to_pause),
                getPendingIntent(context, ACTION_PAUSE));
    }

    builder.addAction(R.drawable.ic_action_stop, context.getString(R.string.action_to_stop), getPendingIntent(context, ACTION_STOP));

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, builder.build());
}
 
开发者ID:DysaniazzZ,项目名称:TopActivity,代码行数:29,代码来源:NotificationUtil.java

示例9: downloadAndUpdateArts

import android.app.PendingIntent; //导入方法依赖的package包/类
private Boolean downloadAndUpdateArts() {
    mArtist = mApp.getDBAccessHelper().getAllArtist();

    int incr = 0;
    for (Artist artist : mArtist) {
        incr++;
        mNotificationBuilder.setContentTitle(getResources().getString(R.string.downloading_artist_arts))
                .setContentText(getResources().getString(R.string.downloading_art_for) + " '" + artist._artistName + "'")
                .setSmallIcon(R.mipmap.ic_music_file);

        Intent intent = new Intent(getApplicationContext(), SettingActivity.class);
        intent.putExtra(Constants.FROM_NOTIFICATION, true);
        intent.putExtra(Constants.FROM_ALBUMS_NOTIFICATION, false);

        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
        mNotificationBuilder.setContentIntent(pendingIntent);

        mNotificationBuilder.setProgress(mArtist.size(), incr, false);
        mNotificationManager.notify(mNotificationId, mNotificationBuilder.build());
        try {
            String cachedUrl = updateArtistArtNow(artist._artistId, artist._artistName);
            Logger.log(cachedUrl);
        } catch (Exception e) {
            continue;
        }
    }

    return true;
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:30,代码来源:ArtistArtDownloadService.java

示例10: initializeNFC

import android.app.PendingIntent; //导入方法依赖的package包/类
public void initializeNFC() {

        if (nfcInit == false) {
            PackageManager pm = getPackageManager();
            nfcSupported = pm.hasSystemFeature(PackageManager.FEATURE_NFC);

            if (nfcSupported == false) {
                return;
            }

            // when is in foreground
            MLog.d(TAG, "starting NFC");
            mAdapter = NfcAdapter.getDefaultAdapter(this);

            // PedingIntent will be delivered to this activity
            mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

            // Setup an intent filter for all MIME based dispatches
            IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
            try {
                ndef.addDataType("*/*");
            } catch (IntentFilter.MalformedMimeTypeException e) {
                throw new RuntimeException("fail", e);
            }
            mFilters = new IntentFilter[]{ ndef, };

            // Setup a tech list for all NfcF tags
            mTechLists = new String[][]{new String[]{NfcF.class.getName()}};
            nfcInit = true;
        }
    }
 
开发者ID:victordiaz,项目名称:phonk,代码行数:32,代码来源:AppRunnerActivity.java

示例11: sendNotifycation

import android.app.PendingIntent; //导入方法依赖的package包/类
private void sendNotifycation(int notifyId, int textId, int drawableId) {
    NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
    Notification notification = new Notification();
    PendingIntent contentIntent = PendingIntent.getActivity(this, notifyId, new Intent(), 0);
    notification.icon = drawableId;
    notification.tickerText = ShareUtils.getString(textId);
    notification.defaults |= 1;
    notification.flags = 16;
    notification.setLatestEventInfo(this, null, null, contentIntent);
    notificationManager.notify(notifyId, notification);
    notificationManager.cancel(notifyId);
    if (LetvUtils.getBrandName().toLowerCase().contains("xiaomi")) {
        ToastUtils.showToast((Context) this, textId);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:16,代码来源:SharePageEditActivity.java

示例12: onCreate

import android.app.PendingIntent; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    ApplicationLoader.postInitApplication();

    lastSelectedDialog = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).getInt("auto_lastSelectedDialog", 0);

    mediaSession = new MediaSession(this, "MusicService");
    setSessionToken(mediaSession.getSessionToken());
    mediaSession.setCallback(new MediaSessionCallback());
    mediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);

    Context context = getApplicationContext();
    Intent intent = new Intent(context, LaunchActivity.class);
    PendingIntent pi = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    mediaSession.setSessionActivity(pi);

    Bundle extras = new Bundle();
    extras.putBoolean(SLOT_RESERVATION_QUEUE, true);
    extras.putBoolean(SLOT_RESERVATION_SKIP_TO_PREV, true);
    extras.putBoolean(SLOT_RESERVATION_SKIP_TO_NEXT, true);
    mediaSession.setExtras(extras);

    updatePlaybackState(null);

    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioPlayStateChanged);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidStarted);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:30,代码来源:MusicBrowserService.java

示例13: createPendingIntent

import android.app.PendingIntent; //导入方法依赖的package包/类
private void createPendingIntent() {
    if (pendingIntent == null) {
        Activity activity = getActivity();
        Intent intent = new Intent(activity, activity.getClass());
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0);
    }
}
 
开发者ID:theGreatWhiteShark,项目名称:mensacard-hack,代码行数:9,代码来源:NfcPlugin.java

示例14: show_notification

import android.app.PendingIntent; //导入方法依赖的package包/类
public void show_notification(int type, int id) {
    long when = System.currentTimeMillis();
    asw_notification = (NotificationManager) MainActivity.this.getSystemService(Context.NOTIFICATION_SERVICE);
    Intent i = new Intent();
    if (type == 1) {
        i.setClass(MainActivity.this, MainActivity.class);
    } else if (type == 2) {
        i.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    } else {
        i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        i.addCategory(Intent.CATEGORY_DEFAULT);
        i.setData(Uri.parse("package:" + MainActivity.this.getPackageName()));
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    }
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(MainActivity.this);
    switch(type){
        case 1:
            builder.setTicker(getString(R.string.app_name));
            builder.setContentTitle(getString(R.string.loc_fail));
            builder.setContentText(getString(R.string.loc_fail_text));
            builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getString(R.string.loc_fail_more)));
            builder.setVibrate(new long[]{350,350,350,350,350});
            builder.setSmallIcon(R.mipmap.ic_launcher);
        break;

        case 2:
            builder.setTicker(getString(R.string.app_name));
            builder.setContentTitle(getString(R.string.app_name));
            builder.setContentText(getString(R.string.loc_perm_text));
            builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getString(R.string.loc_perm_more)));
            builder.setVibrate(new long[]{350, 700, 350, 700, 350});
            builder.setSound(alarmSound);
            builder.setSmallIcon(R.mipmap.ic_launcher);
        break;
    }
    builder.setOngoing(false);
    builder.setAutoCancel(true);
    builder.setContentIntent(pendingIntent);
    builder.setWhen(when);
    builder.setContentIntent(pendingIntent);
    asw_notification_new = builder.getNotification();
    asw_notification.notify(id, asw_notification_new);
}
 
开发者ID:mgks,项目名称:Android-SmartWebView,代码行数:52,代码来源:MainActivity.java

示例15: createNotificationBuilder

import android.app.PendingIntent; //导入方法依赖的package包/类
private NotificationCompat.Builder createNotificationBuilder()
{
    final Resources res = getResources();

    Intent notificationIntent = new Intent(getApplicationContext(), RMBTMainActivity.class);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent openAppIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);


    // src
    //https://developer.android.com/preview/features/notification-channels.html
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        // The user-visible name of the channel.
        CharSequence name = getString(R.string.notification_channel_loop_name);
        // The user-visible description of the channel.
        String description = getString(R.string.notification_channel_loop_description);
        int importance = NotificationManager.IMPORTANCE_LOW;
        NotificationChannel mChannel = new NotificationChannel(RMBT_LOOP_CHANNEL_IDENTIFIER, name, importance);
        // Configure the notification channel.
        mChannel.setDescription(description);
        //mChannel.enableLights(true);
        // Sets the notification light color for notifications posted to this
        // channel, if the device supports this feature.
        //mChannel.setLightColor(Color.BLUE);
        //mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        mNotificationManager.createNotificationChannel(mChannel);
        Log.d("loop","new notification channel established");
    }

    //create NotificationCompat Builder, channel identifier will be ignored on Android <= N according to SO 45465542
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(this, RMBT_LOOP_CHANNEL_IDENTIFIER)
        .setSmallIcon(R.drawable.stat_icon_loop)
        .setContentTitle(res.getText(R.string.loop_notification_title))
        .setTicker(res.getText(R.string.loop_notification_ticker))
        .setContentIntent(openAppIntent);
    
    setNotificationText(builder);
            
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        if (SHOW_STOP_BUTTON) {
            final Intent stopIntent = new Intent(ACTION_STOP, null, getApplicationContext(), getClass());
            final PendingIntent stopPIntent = PendingIntent.getService(getApplicationContext(), 0, stopIntent, 0);
            addStopToNotificationBuilder(builder, stopPIntent);
        }
            if (SHOW_FORCE_BUTTON) {
            final Intent forceIntent = new Intent(ACTION_FORCE, null, getApplicationContext(), getClass());
            final PendingIntent forcePIntent = PendingIntent.getService(getApplicationContext(), 0, forceIntent, 0);
        	addForceToNotificationBuilder(builder, forcePIntent);
        }
    }
    
    return builder;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:57,代码来源:RMBTLoopService.java


注:本文中的android.app.PendingIntent.getActivity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。