本文整理汇总了Java中android.app.TaskStackBuilder类的典型用法代码示例。如果您正苦于以下问题:Java TaskStackBuilder类的具体用法?Java TaskStackBuilder怎么用?Java TaskStackBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TaskStackBuilder类属于android.app包,在下文中一共展示了TaskStackBuilder类的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());
}
示例2: createShortcuts
import android.app.TaskStackBuilder; //导入依赖的package包/类
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
if (shortcuts == null) {
List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
.setShortLabel("Short label")
.setIntents(TaskStackBuilder.create(context)
.addNextIntent(new Intent(Intent.ACTION_VIEW))
.getIntents())
.setRank(0)
.build());
shortcuts = Arrays.asList(enabledShortcuts, disabledShortcuts);
}
return shortcuts;
}
示例3: createShortcuts
import android.app.TaskStackBuilder; //导入依赖的package包/类
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
.setShortLabel(context.getString(34))
.setLongLabel(context.getString(56))
.setIcon(Icon.createWithResource(context, 12))
.setDisabledMessage(context.getString(78))
.setIntents(TaskStackBuilder.create(context)
.addParentStack(ResourcesShortcutActivity.class)
.addNextIntent(new Intent(context, ResourcesShortcutActivity.class)
.setAction(Intent.ACTION_VIEW))
.getIntents())
.setRank(0)
.build());
return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
示例4: createShortcuts
import android.app.TaskStackBuilder; //导入依赖的package包/类
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
.setShortLabel("SHORT_LABEL")
.setIntents(TaskStackBuilder.create(context)
.addParentStack(BackStackShortcutActivity.class)
.addNextIntent(new Intent(Intent.ACTION_VIEW).setClass(context, EmptyActivity1.class))
.addNextIntent(new Intent(Intent.ACTION_VIEW).setClass(context, EmptyActivity2.class))
.addNextIntent(new Intent(context, BackStackShortcutActivity.class)
.setAction(Intent.ACTION_VIEW))
.getIntents())
.setRank(0)
.build());
return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
示例5: createShortcuts
import android.app.TaskStackBuilder; //导入依赖的package包/类
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
.setShortLabel(ShortcutUtils.getActivityLabel(context, SimpleShortcutActivity.class))
.setIntents(TaskStackBuilder.create(context)
.addParentStack(SimpleShortcutActivity.class)
.addNextIntent(new Intent(context, SimpleShortcutActivity.class)
.setAction(Intent.ACTION_VIEW))
.getIntents())
.setRank(0)
.build());
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID_2")
.setShortLabel("SHORT_LABEL")
.setLongLabel("LONG_LABEL")
.setIcon(Icon.createWithResource(context, 123))
.setDisabledMessage("DISABLED_MESSAGE")
.setIntents(TaskStackBuilder.create(context)
.addParentStack(AdvancedShortcutActivity.class)
.addNextIntent(new Intent(context, AdvancedShortcutActivity.class)
.setAction("ACTION"))
.getIntents())
.setRank(1)
.build());
return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
示例6: createShortcuts
import android.app.TaskStackBuilder; //导入依赖的package包/类
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID_2")
.setShortLabel("SHORT_LABEL")
.setLongLabel("LONG_LABEL")
.setIcon(Icon.createWithResource(context, 123))
.setDisabledMessage("DISABLED_MESSAGE")
.setIntents(TaskStackBuilder.create(context)
.addParentStack(AdvancedShortcutActivity.class)
.addNextIntent(new Intent(context, AdvancedShortcutActivity.class)
.setAction("ACTION"))
.getIntents())
.setRank(1)
.build());
return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
示例7: createShortcuts
import android.app.TaskStackBuilder; //导入依赖的package包/类
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
.setShortLabel(ShortcutUtils.getActivityLabel(context, MethodShortcutActivity.class))
.setIntents(TaskStackBuilder.create(context)
.addParentStack(MethodShortcutActivity.class)
.addNextIntent(new Intent(context, MethodShortcutActivity.class)
.setAction(Intent.ACTION_VIEW)
.putExtra("shortbread_method", "shortcutMethod"))
.getIntents())
.setRank(0)
.build());
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
.setShortLabel(ShortcutUtils.getActivityLabel(context, MethodShortcutActivity2.class))
.setIntents(TaskStackBuilder.create(context)
.addParentStack(MethodShortcutActivity2.class)
.addNextIntent(new Intent(context, MethodShortcutActivity2.class)
.setAction(Intent.ACTION_VIEW)
.putExtra("shortbread_method", "shortcutMethod"))
.getIntents())
.setRank(0)
.build());
return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
示例8: createShortcuts
import android.app.TaskStackBuilder; //导入依赖的package包/类
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
.setShortLabel(ShortcutUtils.getActivityLabel(context, TwoMethodShortcutsActivity.class))
.setIntents(TaskStackBuilder.create(context)
.addParentStack(TwoMethodShortcutsActivity.class)
.addNextIntent(new Intent(context, TwoMethodShortcutsActivity.class)
.setAction(Intent.ACTION_VIEW)
.putExtra("shortbread_method", "shortcutMethod1"))
.getIntents())
.setRank(0)
.build());
enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID_2")
.setShortLabel(ShortcutUtils.getActivityLabel(context, TwoMethodShortcutsActivity.class))
.setIntents(TaskStackBuilder.create(context)
.addParentStack(TwoMethodShortcutsActivity.class)
.addNextIntent(new Intent(context, TwoMethodShortcutsActivity.class)
.setAction(Intent.ACTION_VIEW)
.putExtra("shortbread_method", "shortcutMethod2"))
.getIntents())
.setRank(0)
.build());
return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
示例9: sendNodeOfflineNotification
import android.app.TaskStackBuilder; //导入依赖的package包/类
private void sendNodeOfflineNotification(StorjNode storjNode) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
if(prefs.getBoolean(mContext.getString(R.string.pref_enable_notifications),true)) {
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
Intent detailNotificationIntent = new Intent(mContext, StorjNodeDetailActivity.class);
detailNotificationIntent.putExtra(StorjNodeDetailActivity.EXTRA_NODEID, storjNode.getNodeID().getValue());
stackBuilder.addNextIntentWithParentStack(detailNotificationIntent);
PendingIntent operation = stackBuilder.getPendingIntent(storjNode.getNodeID().getValue().hashCode(), PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.storj_symbol)
.setContentTitle(storjNode.getSimpleName().getValue())
.setContentIntent(operation)
.setContentText(mContext.getString(R.string.node_is_offline, storjNode.getSimpleName().getValue()));
NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(storjNode.getNodeID().hashCode(), mBuilder.build());
}
}
示例10: sendNewUserAgentVersionNotification
import android.app.TaskStackBuilder; //导入依赖的package包/类
private void sendNewUserAgentVersionNotification() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
if(prefs.getBoolean(mContext.getString(R.string.pref_enable_notifications),true)) {
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
stackBuilder.addNextIntentWithParentStack(new Intent(mContext, MainActivity.class));
PendingIntent operation = stackBuilder.getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.storj_symbol)
.setContentTitle(mContext.getResources().getString(R.string.new_useragent_version))
.setContentIntent(operation)
.setContentText(mContext.getResources().getString(R.string.new_useragent_version_details));
NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
}
}
示例11: 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());
}
示例12: sendNotification
import android.app.TaskStackBuilder; //导入依赖的package包/类
private void sendNotification() {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setContentTitle("Beacon Reference Application")
.setContentText("An beacon is nearby.")
.setSmallIcon(R.drawable.ic_launcher);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addNextIntent(new Intent(this, MonitoringActivity.class));
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
(NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, builder.build());
}
示例13: goToExperimentList
import android.app.TaskStackBuilder; //导入依赖的package包/类
private void goToExperimentList() {
Intent upIntent = NavUtils.getParentActivityIntent(getActivity());
if (upIntent == null) {
// This is cheating a bit. Currently, upIntent has only been observed to be null
// when we're using panes mode, so here we just assume usePanes==true.
Intent intent =
MainActivity.launchIntent(getActivity(), R.id.navigation_item_experiments,
true);
getActivity().startActivity(intent);
getActivity().finish();
return;
}
if (NavUtils.shouldUpRecreateTask(getActivity(), upIntent) || getArguments().getBoolean(
ARG_CREATE_TASK, false)) {
upIntent.putExtra(MainActivity.ARG_SELECTED_NAV_ITEM_ID,
R.id.navigation_item_experiments);
upIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
// TODO: Transition animation
TaskStackBuilder.create(getActivity()).addNextIntentWithParentStack(upIntent)
.startActivities();
} else {
NavUtils.navigateUpTo(getActivity(), upIntent);
}
}
示例14: 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());
}
示例15: showNotification
import android.app.TaskStackBuilder; //导入依赖的package包/类
private void showNotification() {
// 创建通知栏
Notification.Builder mBuilder = new Notification.Builder(this)
.setSmallIcon(R.drawable.img_tm)
.setContentTitle("标题")
.setContentText("文本");
// 点击跳转到Activity
Intent intent = new Intent(this, MainActivity.class);
// 创建任务栈
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(intent);
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
// 设置跳转
mBuilder.setContentIntent(pendingIntent);
// 获取通知服务
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// 构建通知
Notification notification = mBuilder.build();
// 显示通知
nm.notify(0,notification);
// 启动前台服务
startForeground(0,notification);
}