Intent addFlags - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent addFlags method.

This code example shows how to use the following methods:addFlags, putExtra
  @Override 
  protected void onListItemClick(ListView l, View view, int position, long id) {
    ListAdapter adapter = getListAdapter();    
    if (position >= 0 && position < adapter.getCount()) {
      String packageName = ((AppInfo) adapter.getItem(position)).getPackageName();
      Intent intent = new Intent();
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Browser.BookmarkColumns.URL, "market://details?id=" + packageName);
      setResult(RESULT_OK, intent);
    } else { 
      setResult(RESULT_CANCELED);      
    } 
    finish();
  } 
 
} 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addFlags
    public boolean InstallAppFromMarket(String AppID)
    { 
        boolean result = true;
        try 
        { 
            Intent intent = new Intent(
                Intent.ACTION_VIEW,
                Uri.parse("market://details?id=" + AppID)
                ); 
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
        } 
        catch(Exception e)
        { 
            result = false;
        } 
 
        return result;
    } 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addFlags
        Utilities.LogInfo("Option item selected - " + String.valueOf(item.getTitle()));
 
        switch (itemId)
        { 
            case android.R.id.home:
                Intent intent = new Intent(this, GpsMainActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
 
                break; 
        } 
        return super.onOptionsItemSelected(item);
    } 
 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addFlags
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        Intent intent;
        switch (item.getItemId()) {
            case android.R.id.home:
                intent = new Intent(this, SettingActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                return true; 
        } 
        return false; 
    } 
 
    @Override 
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
 
 
        if (key.equals(SettingActivity.THEME)) {
 
            Intent intent = new Intent(this, AppearanceActivity.class);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getActivity, addFlags, putExtra
	public void createNotification(Context context, Bundle extras)
	{ 
		NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
		String appName = getAppName(this);
 
		Intent notificationIntent = new Intent(this, PushHandlerActivity.class);
		notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
		notificationIntent.putExtra("pushBundle", extras);
 
		PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
		 
		NotificationCompat.Builder mBuilder =
			new NotificationCompat.Builder(context)
				.setDefaults(Notification.DEFAULT_ALL)
				.setSmallIcon(context.getApplicationInfo().icon)
				.setWhen(System.currentTimeMillis())
				.setContentTitle(appName)
				.setTicker(appName)
				.setContentIntent(contentIntent);
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addFlags, setAction
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:  // See ActionBar#setDisplayHomeAsUpEnabled()
                Intent intent = new Intent(this, FdnSetting.class);
                intent.setAction(Intent.ACTION_MAIN);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                finish(); 
                return true; 
 
            case MENU_ADD:
                addContact(); 
                return true; 
 
            case MENU_EDIT:
                editSelected(); 
                return true; 
 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addCategory, addFlags, sleep
     * Launches and activity and queries for errors. 
     * @param packageName {@link String} the package name of the application to launch. 
     * @return  {@link Collection} of {@link ProcessErrorStateInfo} detected during the app launch. 
     */ 
    private Collection<ProcessErrorStateInfo> launchActivity(String packageName) {
        Intent homeIntent = new Intent(Intent.ACTION_MAIN);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
        Intent intent = mPackageManager.getLaunchIntentForPackage(packageName);
 
        // We check for any Crash or ANR dialogs that are already up, and we ignore them.  This is 
        // so that we don't report crashes that were caused by prior apps (which those particular 
        // tests should have caught and reported already).  Otherwise, test failures would cascade 
        // from the initial broken app to many/all of the tests following that app's launch. 
        final Collection<ProcessErrorStateInfo> preErr = mActivityManager.getProcessesInErrorState();
 
        // Launch Activity 
        mContext.startActivity(intent);
 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addFlags, setClassName
	{ 
		super.onStart(); 
		Looper.prepare();
 
		Log.d(TAG, "Starting package/activity: " + getTargetContext().getPackageName() + "/" + activityClassName);
		Intent intent = new Intent();
		intent.setClassName(getTargetContext(), activityClassName);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		Activity activity = startActivitySync(intent);
		if (activity instanceof InstrumentedActivity)
		{ 
			((InstrumentedActivity)activity).setInstrumentation(this);
		} 
		waitForIdleSync();
	} 
 
	@Override 
	public boolean onException(Object obj, Throwable e)
	{ 
		// log, but ignore exceptions 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addFlags, putExtra
  } 
 
  @Override 
  protected void onListItemClick(ListView l, View view, int position, long id) {
    if (cursor.moveToPosition(position)) {
      Intent intent = new Intent();
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Browser.BookmarkColumns.TITLE, cursor.getString(TITLE_COLUMN));
      intent.putExtra(Browser.BookmarkColumns.URL, cursor.getString(URL_COLUMN));
      setResult(RESULT_OK, intent);
    } else { 
      setResult(RESULT_CANCELED);
    } 
    finish();
  } 
} 
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addFlags, putExtra, setClass, setClipData
    @SuppressLint("NewApi") 
    public static Intent createChooser(Intent target, CharSequence title) {
        if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
            return Intent.createChooser(target, title);
        } 
        Intent intent = new Intent();
        intent.setClass(Application.getLastInstance(), ChooserActivity.class);
        intent.putExtra(Intent.EXTRA_INTENT, target);
        if (title != null) {
            intent.putExtra(Intent.EXTRA_TITLE, title);
        } 
        int permFlags = target.getFlags()
                & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        if (permFlags != 0 && VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
            ClipData targetClipData = target.getClipData();
            if (targetClipData == null && target.getData() != null) {
                ClipData.Item item = new ClipData.Item(target.getData());
                String[] mimeTypes;
                if (target.getType() != null) {
                    mimeTypes = new String[]{

9
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Intent addFlags Questions & Answers:

Other Intent addFlags Examples

154:							// adding HashList to ArrayList
155:							productsList.add(map);
156:						}
157:					} else {
158:						// no products found

Read More

31:	    				userFunctions.logoutUser(getApplicationContext());
32:	    				Intent login = new Intent(getApplicationContext(), LoginActivity.class);
33:	    	        	login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
34:	    	        	startActivity(login);
35:	    	        	// Closing dashboard screen
-
41:	        	// user is not logged in show login screen
42:	        	Intent login = new Intent(getApplicationContext(), LoginActivity.class);
43:	        	login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
44:	        	startActivity(login);
45:	        	// Closing dashboard screen

Read More

71:								Intent dashboard = new Intent(getApplicationContext(), DashboardActivity.class);
72:								// Close all views before launching Dashboard
73:								dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
74:								startActivity(dashboard);
75:								// Close Registration Screen

Read More

addFlags Method Overview
Add additional flags to the intent (or with existing flags value).
See Code Examples for other Android Intent Methods: