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


Java TaskStackBuilder.addParentStack方法代码示例

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


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

示例1: createAuthNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void createAuthNotification()
{
    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(getContext(), AuthenticatorActivity.AUTH_NOTIFICATION_CHANNEL_ID)
                .setContentTitle(getContext().getString(R.string.sync_ntf_needs_reauthentication_title))
                .setContentText(getContext().getString(R.string.sync_ntf_needs_reauthentication_description))
                .setSmallIcon(R.mipmap.ic_launcher)
                .setAutoCancel(true);

    Intent intent = new Intent(getContext(), AuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, getContext().getString(R.string.account_type));
    intent.putExtra(AuthenticatorActivity.ARG_AUTH_TOKEN_TYPE, AuthenticatorActivity.ARG_AUTH_TOKEN_TYPE);
    intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, false);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(getContext());
    stackBuilder.addParentStack(AuthenticatorActivity.class);
    stackBuilder.addNextIntent(intent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);

    NotificationManager ntfMgr =
            (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
    ntfMgr.notify(AuthenticatorActivity.AUTH_NOTIFICATION_ID, builder.build());
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:25,代码来源:CalendarSyncAdapter.java

示例2: reminder

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

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

        mBuilder.setSmallIcon(R.drawable.sos);
        mBuilder.setContentTitle("Reminder !");
        mBuilder.setContentText(reminder_text);

        Intent resultIntent = new Intent(this, Location_event.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addParentStack(Location_event.class);

// Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(resultPendingIntent);

        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

// notificationID allows you to update the notification later on.
        mNotificationManager.notify(0, mBuilder.build());

    }
 
开发者ID:SkylineLabs,项目名称:FindX,代码行数:25,代码来源:digiPune.java

示例3: showAppNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void showAppNotification(){
    mBuilder.setSmallIcon(R.drawable.ic_notification);
    mBuilder.setLargeIcon(mIcon);
        Intent resultIntent = new Intent(this, MainActivity.class);

    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(MainActivity.class);

    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent =
            stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);

    startForeground(SERVICE_IDENTIFIER, mBuilder.build());
}
 
开发者ID:SecUSo,项目名称:privacy-friendly-netmonitor,代码行数:23,代码来源:PassiveService.java

示例4: showNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
public void showNotification() {
    NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_favorite_black_24dp)
            .setContentTitle("Test")
            .setContentText("123");
    // 点击通知触发的 Intent
    Intent resulteIntent = new Intent(this, MainActivity.class);
    // 任务栈 Builder
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resulteIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(resultPendingIntent);
    // 构建通知
    Notification notification = builder.build();
    // 通知管理器
    NotificationManager notificationMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationMgr.notify(NOTIFY_ID, notification);
}
 
开发者ID:Codpoe,项目名称:Learn,代码行数:21,代码来源:LearnService.java

示例5: showSimpleNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void showSimpleNotification() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext())
            .setSmallIcon(android.R.drawable.ic_notification_overlay)
            .setAutoCancel(true)
            .setContentTitle(getString(R.string.normal_notification_title))
            .setContentText(getString(R.string.normal_notification_text))
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(getContext());
    stackBuilder.addParentStack(MainActivity.class);

    Intent resultIntent = new Intent(getContext(), MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    PendingIntent resultPendingIntent = stackBuilder
            .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);

    NotificationManager notificationManager = (NotificationManager)
            getContext().getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID_MAIN_MENU, builder.build());
}
 
开发者ID:google,项目名称:talkback,代码行数:23,代码来源:NotificationTest.java

示例6: setNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
/**
 * Helper to set Notification when the alarm goes off
 */
private void setNotification() {
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
    mBuilder.setSmallIcon(R.mipmap.ic_bug_report_white_36dp);
    mBuilder.setContentTitle("Found a Tick?");
    mBuilder.setContentText("Click here to make an Observation of encountered Tick!");
    Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    mBuilder.setSound(uri);

    Intent resultIntent = new Intent(mContext, ObservationMasterActivity.class);
    // put the extras in addObservationIntent to perform fragment Transaction efficiently.
    resultIntent.putExtra(UserActivityMasterActivity.KEY_ACTIVITY_ADD_OBS, 1);
    resultIntent.putExtra(UserActivityMasterActivity.KEY_ACTIVITY_ID, ongoingActivityObj.getId());
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
    stackBuilder.addParentStack(ObservationMasterActivity.class);

    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);


    NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    // notificationID allows you to update the notification later on.
    mNotificationManager.notify(12345, mBuilder.build());
}
 
开发者ID:pmk2429,项目名称:investickation,代码行数:29,代码来源:ActivityRunningFragment.java

示例7: setNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void setNotification() {
    final Intent resultIntent = new Intent(this, MainActivity.class);
    final TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);
    final PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder = new NotificationCompat.Builder(this)
            .setContentText(getString(R.string.notification_bt_on))
            .setContentTitle(getString(R.string.device_hive))
            .setSmallIcon(R.drawable.ic_le_service)
            .setAutoCancel(false)
            .setOngoing(true)
            .setContentIntent(resultPendingIntent);

    mNotificationManager.notify(LE_NOTIFICATION_ID, mBuilder.build());
}
 
开发者ID:devicehive,项目名称:android-ble,代码行数:18,代码来源:BluetoothLeService.java

示例8: sendNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
public static void sendNotification(final Context context,final String postfix,final String message){
	final Notification.Builder mBuilder =
	        new Notification.Builder(context)
	        .setSmallIcon(R.drawable.ic_launcher)
	        .setContentTitle(context.getText(R.string.app_name)+" "+postfix)
	        .setContentText(message);
	// Creates an explicit intent for an Activity in your app
	final Intent resultIntent = new Intent(context, MainActivity.class);

	// The stack builder object will contain an artificial back stack for the
	// started Activity.
	// This ensures that navigating backward from the Activity leads out of
	// your application to the Home screen.
	final TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
	// Adds the back stack for the Intent (but not the Intent itself)
	stackBuilder.addParentStack(MainActivity.class);
	// Adds the Intent that starts the Activity to the top of the stack
	stackBuilder.addNextIntent(resultIntent);
	PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
	mBuilder.setContentIntent(resultPendingIntent);
	final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
	if (mNotificationManager!=null) {
           // mId allows you to update the notification later on.
           int mId = 0;
           mNotificationManager.notify(mId, mBuilder.build());

           Analytics.getInstance().logEvent(TAG, "sendNotification", "message");
       }
}
 
开发者ID:videgro,项目名称:Ships,代码行数:30,代码来源:Utils.java

示例9: createSettingsIntent

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
/**
 * Creates an intent to open Fit Notifications settings when notification is clicked.
 */
private PendingIntent createSettingsIntent() {
    // Creates an explicit intent for the SettingsActivity in the app
    Intent settingsIntent = new Intent(this, SettingsActivity.class);

    // The stack builder object will contain an artificial back stack for the started Activity.
    // This ensures that navigating backward from the Activity leads out of the application to
    // the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(SettingsActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(settingsIntent);
    return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:18,代码来源:NLService.java

示例10: onReceive

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    //Do some operations, like loading values from a file, and show it in the notification or pass it in the calledActivity
    String loadedString = "This is a string loaded from the Receiver";

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

    //Building our custom Notification
    NotificationCompat.Builder mBuilder =
            (NotificationCompat.Builder) new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_flag) //Set icon
                    .setContentTitle("Notification Title")
                    .setContentText("Click to call calledActivity")
                    .setSound(alarmSound)
                    .setColor(Color.argb(0,21,101,192)) //Color your notification
                    .setVibrate(new long[]{300, 300, 300, 300, 300}) //Vibration intensity
                    .setAutoCancel(true);

    //setting activity called clicking on the notification
    Intent resultIntent = new Intent(context, calledActivity.class);
    resultIntent.putExtra(calledActivity.WORD, loadedString);
    resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    //Building virtual stack, allowing the user to press back to go back to the main activity
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(calledActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder.setContentIntent(resultPendingIntent);
    notificationManager.notify(MainActivity.notifId, mBuilder.build());
}
 
开发者ID:Cesarsk,项目名称:Android-Notifications-Sample,代码行数:37,代码来源:NotificationReceiver.java

示例11: createStreamNotification

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private Notification createStreamNotification(StreamInfo stream, @Nullable Bitmap image, boolean showViewers, Context context) {
    Intent resultIntent = LiveStreamActivity.createLiveStreamIntent(stream, false, context);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(MyStreamsActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    PendingIntent clickIntent = stackBuilder.getPendingIntent(
            stream.getChannelInfo().getDisplayName().hashCode(),
            PendingIntent.FLAG_UPDATE_CURRENT
    );

    NotificationTextData textData = constructStreamNotificationText(stream, context);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setAutoCancel(false)
            .setContentTitle(textData.getTitle())
            .setContentText(textData.getContent())
            .setGroup(GROUP_KEY)
            .setWhen(stream.getStartedAt())
            .setShowWhen(true)
            .setSmallIcon(R.drawable.ic_notification_icon_refresh)
            .setColor(ContextCompat.getColor(context, R.color.primary))
            .setContentIntent(clickIntent);

    if (image != null) {
        mBuilder.setLargeIcon(image);
    }

    if (showViewers) {
        mBuilder.setSubText(textData.getSubtext());
    }

    return mBuilder.build();
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:35,代码来源:NotificationReceiver.java

示例12: startData

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
void startData(){
        try {
            setMobileDataEnabled(this.getApplicationContext(), true);
        }
        catch(Exception e){
            //    Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

            mBuilder.setSmallIcon(R.drawable.sos);
            mBuilder.setContentTitle("Reminder !");
            mBuilder.setContentText(e.toString());

            Intent resultIntent = new Intent(this, Location_event.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(Location_event.class);

// Adds the Intent that starts the Activity to the top of the stack
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);

            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

// notificationID allows you to update the notification later on.
            mNotificationManager.notify(0, mBuilder.build());

        }
    }
 
开发者ID:SkylineLabs,项目名称:FindX,代码行数:29,代码来源:digiPune.java

示例13: stopData

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
void stopData()
    {
        try {
            setMobileDataEnabled(this.getApplicationContext(), false);
        }
        catch(Exception e){
            // Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

            mBuilder.setSmallIcon(R.drawable.sos);
            mBuilder.setContentTitle("Reminder !");
            mBuilder.setContentText(e.toString());

            Intent resultIntent = new Intent(this, Location_event.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(Location_event.class);

// Adds the Intent that starts the Activity to the top of the stack
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);

            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

// notificationID allows you to update the notification later on.
            mNotificationManager.notify(0, mBuilder.build());

        }
    }
 
开发者ID:SkylineLabs,项目名称:FindX,代码行数:30,代码来源:digiPune.java

示例14: setMobileDataEnabled

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
private void setMobileDataEnabled(Context context, boolean enabled) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        final ConnectivityManager conman = (ConnectivityManager)  context.getSystemService(Context.CONNECTIVITY_SERVICE);
        final Class conmanClass = Class.forName(conman.getClass().getName());
        final Field connectivityManagerField = conmanClass.getDeclaredField("mService");
        connectivityManagerField.setAccessible(true);
        final Object connectivityManager = connectivityManagerField.get(conman);
        final Class connectivityManagerClass =  Class.forName(connectivityManager.getClass().getName());
        final Method setMobileDataEnabledMethod = connectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
        setMobileDataEnabledMethod.setAccessible(true);

        try{
            setMobileDataEnabledMethod.invoke(connectivityManager, enabled);
        }

        catch(Exception e){
            //Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

            mBuilder.setSmallIcon(R.drawable.sos);
            mBuilder.setContentTitle("Reminder !");
            mBuilder.setContentText(e.toString());

            Intent resultIntent = new Intent(this, Location_event.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(Location_event.class);

// Adds the Intent that starts the Activity to the top of the stack
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);

            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

// notificationID allows you to update the notification later on.
            mNotificationManager.notify(0, mBuilder.build());

        }
    }
 
开发者ID:SkylineLabs,项目名称:FindX,代码行数:39,代码来源:digiPune.java

示例15: show

import android.app.TaskStackBuilder; //导入方法依赖的package包/类
public Notification show(Map map) {

            Bitmap iconBmp = null;
            String iconName = (String) map.get("icon");
            if (iconName != null) iconBmp = BitmapFactory.decodeFile(getAppRunner().getProject().getFullPathForFile(iconName));

            Intent intent = new Intent(getContext(), MyBroadcastReceiver.class);
            PendingIntent pendingIntent = PendingIntent.getBroadcast(getContext(), 0, intent, 0);

            // Creates an explicit intent for an Activity in your app
            Intent resultIntent = new Intent(getContext(), AppRunnerActivity.class);
            // The stack builder object will contain an artificial back stack for navigating backward from the Activity leads out your application to the Home screen.
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(getContext());
            stackBuilder.addParentStack(AppRunnerActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

            int id = ((Number) map.get("id")).intValue();
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getContext())
                    .setSmallIcon(R.drawable.app_icon)
                    .setContentTitle((CharSequence) map.get("title"))
                    .setContentText((CharSequence) map.get("description"))
                    .setLights(Color.parseColor((String) map.get("color")), 1000, 1000)
                    .setLargeIcon(iconBmp)
                    .setAutoCancel((Boolean) map.get("autocancel"))
                    .setTicker((String)map.get("ticker"))
                    .setSubText((CharSequence) map.get("subtext"))
                    .setDeleteIntent(pendingIntent)
                    .setContentIntent(resultPendingIntent);

            mNotificationManager.notify(id, mBuilder.build());

            return this;
        }
 
开发者ID:victordiaz,项目名称:phonk,代码行数:35,代码来源:PApp.java


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