Java Code Examples for android.content.Intent.makeRestartActivityTask()

The following are Jave code examples for showing how to use makeRestartActivityTask() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: orgzly-android   File: ActivityUtils.java   View Source Code Vote up 6 votes
public static PendingIntent mainActivityPendingIntent(Context context, long bookId, long noteId) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, bookId, noteId);
    Intent intent = Intent.makeRestartActivityTask(new ComponentName(context, MainActivity.class));

    intent.putExtra(AppIntent.EXTRA_BOOK_ID, bookId);
    intent.putExtra(AppIntent.EXTRA_NOTE_ID, noteId);

    return PendingIntent.getActivity(
            context,
            Long.valueOf(noteId).intValue(),
            intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
}
 
Example 2
Project: orgzly-android   File: ListWidgetProvider.java   View Source Code Vote up 6 votes
private static void updateAppWidgetLayout(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    Filter filter = getFilter(context, appWidgetId);

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.list_widget);

    Intent serviceIntent = new Intent(context, ListWidgetService.class);
    serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    serviceIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, filter.getQuery());
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));

    // Tell ListView where to get the data from
    remoteViews.setRemoteAdapter(R.id.list_widget_list_view, serviceIntent);

    remoteViews.setEmptyView(R.id.list_widget_list_view, R.id.list_widget_empty_view);
    if (filter.getQuery() == null) {
        remoteViews.setTextViewText(R.id.list_widget_empty_view, context.getString(R.string.select_a_filter_long));
    } else {
        remoteViews.setTextViewText(R.id.list_widget_empty_view, context.getString(R.string.no_notes_found_after_search));
    }

    // Rows - open note
    final Intent onClickIntent = new Intent(context, ListWidgetProvider.class);
    onClickIntent.setAction(AppIntent.ACTION_CLICK_LIST_WIDGET);
    onClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
    final PendingIntent onClickPendingIntent = PendingIntent.getBroadcast(context, 0,
            onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    remoteViews.setPendingIntentTemplate(R.id.list_widget_list_view, onClickPendingIntent);

    // Plus icon - new note
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_add, ShareActivity.createNewNoteIntent(context, filter));

    // Logo - open query
    Intent openIntent = Intent.makeRestartActivityTask(new ComponentName(context, MainActivity.class));
    openIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, filter.getQuery());
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_icon, PendingIntent.getActivity(context, 0, openIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    Intent filterSelectIntent = new Intent(context, FilterSelectDialogActivity.class);
    filterSelectIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    filterSelectIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_bar, PendingIntent.getActivity(context, 0, filterSelectIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    remoteViews.setTextViewText(
            R.id.list_widget_header_filter,
            filter.getName());

    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
 
Example 3
Project: boohee_v5.6   File: IntentCompatHoneycomb.java   View Source Code Vote up 5 votes
public static Intent makeRestartActivityTask(ComponentName mainActivity) {
    return Intent.makeRestartActivityTask(mainActivity);
}