android.content.Intent#addFlags ( )源码实例Demo

下面列出了android.content.Intent#addFlags ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xDrip-plus   文件: GcmListenerSvc.java
private void sendNotification(String body, String title) {
    Intent intent = new Intent(this, Home.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Notification.Builder notificationBuilder = (Notification.Builder) new Notification.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(title)
            .setContentText(body)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

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

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
 
源代码2 项目: XKnife-Android   文件: RomEntity.java
private void showMiuiInstalledAppDetails(Context context) {
            String rom = super.getPropertyValue();
            String pkg = context.getPackageName();
            if ("V6".equals(rom)) {
                Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
                intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
                intent.putExtra("extra_pkgname", pkg);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                try {
                    context.startActivity(intent);
                } catch (Exception e) {
                }

//            Activity activity = PageSwitcher.peekActivityStack();
//            if (Util.isIntentAvailable(activity, intent)) {
//                activity.startActivityForResult(intent, 2);
//            } else {
//                L.e("Intent is not available!");
//            }
            } else {
                NotProguardUtils.showInstalledAppDetails(context, pkg);
            }
        }
 
源代码3 项目: android   文件: ExternalOpenVPNService.java
private void startProfile(VpnProfile vp) {
    Intent vpnPermissionIntent = VpnService.prepare(ExternalOpenVPNService.this);
    /* Check if we need to show the confirmation dialog,
     * Check if we need to ask for username/password */

    int needpw = vp.needUserPWInput(false);

    if (vpnPermissionIntent != null || needpw != 0) {
        Intent shortVPNIntent = new Intent(Intent.ACTION_MAIN);
        shortVPNIntent.setClass(getBaseContext(), ht.vpn.android.LaunchVPN.class);
        shortVPNIntent.putExtra(ht.vpn.android.LaunchVPN.EXTRA_KEY, vp.getUUIDString());
        shortVPNIntent.putExtra(ht.vpn.android.LaunchVPN.EXTRA_HIDELOG, true);
        shortVPNIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(shortVPNIntent);
    } else {
        VPNLaunchHelper.startOpenVpn(vp, getBaseContext());
    }

}
 
public static void requestPermissions(@NonNull Context context, @NonNull String[] permissions,
        @NonNull ResultReceiver resultReceiver) {
    Intent callIntent = new Intent(context, PermissionRequestActivity.class);
    callIntent.putExtra(EXTRA_PERMISSIONS, permissions);
    callIntent.putExtra(EXTRA_CALLBACK, resultReceiver);
    // NOTE: FLAG_ACTIVITY_SINGLE_TASK causes Activity#onActivityResult()
    // being called prematurely. FLAG_ACTIVITY_SINGLE_TOP, on the other
    // hand, does not cause that.
    callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP
            | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
        context.startActivity(callIntent);
    } else {
        NotificationUtils.createNotificationChannel(context);
        NotificationUtils.notify(context, NOTIFICATION_ID, REQUEST_CODE, callIntent, NOTIFICATION_CONTENT);
    }
}
 
源代码5 项目: openboard   文件: SetupActivity.java
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = new Intent();
    intent.setClass(this, SetupWizardActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    if (!isFinishing()) {
        finish();
    }
}
 
源代码6 项目: GreenDamFileExploere   文件: OpenFileUtil.java
public static Intent getAllIntent(String param) {

        Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setAction(android.content.Intent.ACTION_VIEW);
        Uri uri = Uri.fromFile(new File(param));
        intent.setDataAndType(uri, "*/*");
        return intent;
    }
 
源代码7 项目: edx-app-android   文件: Router.java
public void showCourseDiscussionPostsForDiscussionTopic(Activity activity, DiscussionTopic topic,
                                                        String topicId, String threadId,
                                                        EnrolledCoursesResponse courseData) {
    Intent showDiscussionPostsIntent = new Intent(activity, CourseDiscussionPostsActivity.class);
    showDiscussionPostsIntent.putExtra(EXTRA_COURSE_DATA, courseData);
    if (topic != null) {
        showDiscussionPostsIntent.putExtra(EXTRA_DISCUSSION_TOPIC, topic);
    }
    showDiscussionPostsIntent.putExtra(Router.EXTRA_DISCUSSION_TOPIC_ID, topicId);
    showDiscussionPostsIntent.putExtra(Router.EXTRA_DISCUSSION_THREAD_ID, threadId);
    showDiscussionPostsIntent.putExtra(CourseDiscussionPostsThreadFragment.ARG_DISCUSSION_HAS_TOPIC_NAME, topic != null);
    showDiscussionPostsIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    activity.startActivity(showDiscussionPostsIntent);
}
 
源代码8 项目: mobile-manager-tool   文件: FileUtil.java
public static Intent getImageFileIntent( String param ) {

        Intent intent = new Intent("android.intent.action.VIEW");
        intent.addCategory("android.intent.category.DEFAULT");
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Uri uri = Uri.fromFile(new File(param ));
        intent.setDataAndType(uri, "image/*");
        return intent;
    }
 
源代码9 项目: AppOpsX   文件: SettingsActivity.java
private void switchLanguage() {
  LangHelper.updateLanguage(getContext());
  LangHelper.updateLanguage(getContext().getApplicationContext());

  Intent it = new Intent(getActivity(), MainActivity.class);
  it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
  it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  getActivity().startActivity(it);
  getActivity().finish();
}
 
源代码10 项目: Android   文件: DownloadImage.java
public void prepareShareIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_TEXT, "Just for test my app ");
    shareIntent.putExtra(Intent.EXTRA_STREAM, image_path);
    shareIntent.setType("image/*");
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    mContext.startActivity(Intent.createChooser(shareIntent, "Share Opportunity"));
}
 
源代码11 项目: AndroidDocumentViewer   文件: IntentUtils.java
static Intent getTextFileIntent(String paramString, boolean paramBoolean) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (paramBoolean) {
        Uri uri1 = Uri.parse(paramString);
        intent.setDataAndType(uri1, "text/plain");
    }
    return intent;
}
 
源代码12 项目: android-dev-challenge   文件: DetailActivity.java
/**
 * Uses the ShareCompat Intent builder to create our Forecast intent for sharing.  All we need
 * to do is set the type, text and the NEW_DOCUMENT flag so it treats our share as a new task.
 * See: http://developer.android.com/guide/components/tasks-and-back-stack.html for more info.
 *
 * @return the Intent to use to share our weather forecast
 */
private Intent createShareForecastIntent() {
    Intent shareIntent = ShareCompat.IntentBuilder.from(this)
            .setType("text/plain")
            .setText(mForecastSummary + FORECAST_SHARE_HASHTAG)
            .getIntent();
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    return shareIntent;
}
 
源代码13 项目: gilgamesh   文件: GilgaService.java
private void startBroadcasting() {
  //  if(D) Log.d(TAG, "ensure discoverable");
   if (mBluetoothAdapter.getScanMode() !=
      BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
    	
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 3600);
        discoverableIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(discoverableIntent);
        
    }
   
   if (!mBluetoothAdapter.isDiscovering())
	   mBluetoothAdapter.startDiscovery();

   if (mDirectChatSession == null)
   {
	   mDirectChatSession = new DirectMessageSession(this, mHandler);
	   mDirectChatSession.start();
   }
   else {
       // Only if the state is STATE_NONE, do we know that we haven't started already
       if (mDirectChatSession.getState() == DirectMessageSession.STATE_NONE) {
         // Start the Bluetooth chat services
    	   mDirectChatSession.start();
       }
       
   }
    
}
 
源代码14 项目: android-app   文件: ReadArticleActivity.java
private boolean handleTagClicked(String url) {
    final String tagUrlPrefix = "tag://";

    if (!url.startsWith(tagUrlPrefix)) return false;

    long tagId;
    try {
        tagId = Long.parseLong(url.substring(tagUrlPrefix.length()));
    } catch (NumberFormatException nfe) {
        Log.w(TAG, "handleTagClicked() couldn't handle tag URL: " + url);
        return true;
    }

    Tag tag = null;
    for (Tag t : article.getTags()) {
        if (t.getId() == tagId) {
            tag = t;
            break;
        }
    }

    if (tag == null) {
        Log.w(TAG, "handleTagClicked() couldn't find tag by ID: " + tagId);
        return true;
    }

    Intent intent = new Intent(this, MainActivity.class);
    intent.putExtra(MainActivity.PARAM_TAG_LABEL, tag.getLabel());

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    startActivity(intent);

    return true;
}
 
@Override
public PendingIntent onSettingPendingIntent() {
    Intent clickIntentActivity = new Intent(ZadakNotification.mSingleton.mContext, mActivity);
    clickIntentActivity.setAction(BroadcastActions.ACTION_CLICK_INTENT);
    clickIntentActivity.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    clickIntentActivity.setPackage(ZadakNotification.mSingleton.mContext.getPackageName());

    if (mBundle != null) {
        clickIntentActivity.putExtras(mBundle);
    }
    return PendingIntent.getActivity(ZadakNotification.mSingleton.mContext, mIdentifier, clickIntentActivity,
            PendingIntent.FLAG_UPDATE_CURRENT);
}
 
源代码16 项目: incubator-taverna-mobile   文件: LoginFragment.java
@OnClick(R.id.bRegister)
public void register(View v) {
    if (Build.VERSION.SDK_INT < 15) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse(myExperimentURL));
        startActivity(intent);
    } else {
        CustomTabsIntent.Builder customTabsIntentBuilder = new CustomTabsIntent.Builder();
        CustomTabsIntent customTabsIntent = customTabsIntentBuilder.build();
        customTabsIntent.launchUrl(getActivity(), Uri.parse(myExperimentURL));
    }
}
 
源代码17 项目: SAI   文件: ConfirmationIntentWrapperActivity.java
public static void start(Context c, int sessionId, Intent confirmationIntent) {
    Intent intent = new Intent(c, ConfirmationIntentWrapperActivity.class);
    intent.putExtra(EXTRA_CONFIRMATION_INTENT, confirmationIntent);
    intent.putExtra(RootlessSAIPIService.EXTRA_SESSION_ID, sessionId);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    c.startActivity(intent);
}
 
源代码18 项目: MyBookshelf   文件: BookInfoEditActivity.java
public static void startThis(Context context, String noteUrl) {
    Intent intent = new Intent(context, BookInfoEditActivity.class);
    intent.putExtra("noteUrl", noteUrl);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
private void performActionOnReceiveForWidget(Context context, Intent intent, int widgetId) {
    AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
    LocationsDbHelper locationsDbHelper = LocationsDbHelper.getInstance(context);
    WidgetSettingsDbHelper widgetSettingsDbHelper = WidgetSettingsDbHelper.getInstance(context);
    Long locationId = widgetSettingsDbHelper.getParamLong(widgetId, "locationId");
    if (locationId == null) {
        currentLocation = locationsDbHelper.getLocationByOrderId(0);
        if (!currentLocation.isEnabled()) {
            currentLocation = locationsDbHelper.getLocationByOrderId(1);
        }
    } else {
        currentLocation = locationsDbHelper.getLocationById(locationId);
    }
    switch (intent.getAction()) {
        case "org.thosp.yourlocalweather.action.WEATHER_UPDATE_RESULT":
        case "android.appwidget.action.APPWIDGET_UPDATE":
            if (!servicesStarted) {
                onEnabled(context);
                servicesStarted = true;
            }
            onUpdate(context, widgetManager, new int[] {widgetId});
            break;
        case Intent.ACTION_LOCALE_CHANGED:
        case Constants.ACTION_APPWIDGET_THEME_CHANGED:
        case Constants.ACTION_APPWIDGET_SETTINGS_SHOW_CONTROLS:
            refreshWidgetValues(context);
            break;
        case Constants.ACTION_APPWIDGET_UPDATE_PERIOD_CHANGED:
            onEnabled(context);
            break;
        case Constants.ACTION_APPWIDGET_CHANGE_SETTINGS:
            onUpdate(context, widgetManager, new int[]{ widgetId});
            break;
    }

    if (intent.getAction().startsWith(Constants.ACTION_APPWIDGET_SETTINGS_OPENED)) {
        String[] params = intent.getAction().split("__");
        String widgetIdTxt = params[1];
        widgetId = Integer.parseInt(widgetIdTxt);
        openWidgetSettings(context, widgetId, params[2]);
    } else if (intent.getAction().startsWith(Constants.ACTION_APPWIDGET_START_ACTIVITY)) {
        AppPreference.setCurrentLocationId(context, currentLocation);
        Long widgetActionId = intent.getLongExtra("widgetAction", 1);
        Class activityClass = WidgetActions.getById(widgetActionId, "action_current_weather_icon").getActivityClass();
        Intent activityIntent = new Intent(context, activityClass);
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(activityIntent);
    } else if (intent.getAction().startsWith(Constants.ACTION_APPWIDGET_CHANGE_LOCATION)) {
        changeLocation(widgetId, locationsDbHelper, widgetSettingsDbHelper);
        GraphUtils.invalidateGraph();
        onUpdate(context, widgetManager, new int[]{widgetId});
    } else if (intent.getAction().startsWith(Constants.ACTION_FORCED_APPWIDGET_UPDATE)) {
        if (!WidgetRefreshIconService.isRotationActive) {
            sendWeatherUpdate(context, widgetId);
        }
        onUpdate(context, widgetManager, new int[]{ widgetId});

    }
}
 
源代码20 项目: AndroidUtilCode   文件: IntentUtils.java
private static Intent getIntent(final Intent intent, final boolean isNewTask) {
    return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent;
}
 
 方法所在类
 同类方法