Activity startActivity - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:finish, startActivity
			}); 
			alertDialogBuilder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
				@Override 
				public void onClick(final DialogInterface pDialog, final int pWhich) {
					if(pCancelIntent != null) {
						pActivity.startActivity(pCancelIntent);
					} 
					pActivity.finish();
				} 
			}) 
			.create().show();
			return true; 
		}else{ 
			return false; 
		} 
	} 
 
	// =========================================================== 
	// Inner and Anonymous Classes 
	// =========================================================== 
9
CodeRank
This code example shows how to use the following methods:startActivity, getString
8
CodeRank
This code example shows how to use the following methods:startActivity
     */ 
    public static void askOAuth(Activity activity)
    { 
        try 
        { 
            ITroveboxApi mTrovebox = Preferences.getApi(activity);
            String url = mTrovebox.getOAuthUrl("Trovebox Android App",
                    getCallbackUrl(activity),
                    activity);
            activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
                    .parse(url)));
        } catch (Exception ex)
        { 
            GuiUtils.error(TAG, null, ex, activity);
        } 
    } 
 
    /** 
     * Verify received response from the browser 
     *  
7
CodeRank
This code example shows how to use the following methods:finish, startActivity, setClass, makeText
 
    protected void onPostExecute(String message) {
        dialog.hide();
        dialog.cancel();
 
        Toast.makeText(context,message,Toast.LENGTH_LONG).show();
 
		Intent i = new Intent().setClass(context, TabWidget.class);
		context.startActivity(i);
 
        context.finish();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:finish, startActivity
      this.activityClass = activityClass;
      this.name = name;
    } 
 
    public void launch(Activity activity) {
      activity.startActivity(new Intent(activity, activityClass));
      activity.finish();
    } 
  } 
 
  private final LayoutInflater inflater;
 
  public PicassoSampleAdapter(Context context) {
    inflater = LayoutInflater.from(context);
  } 
 
  @Override public int getCount() { 
    return Sample.values().length;
  } 
 
8
CodeRank
This code example shows how to use the following methods:getApplication, startActivity
		if ( sMovie != null ) {
			 
			sMovie.finish ();
		} 
	 
		Intent movie = new Intent ( sActivity.getApplication (), MoaiMoviePlayer.class );
		movie.putExtra ( "url", url );
		sActivity.startActivity ( movie );
	} 
 
	//----------------------------------------------------------------// 
	public static void play () { 
		 
		if ( sMovie != null ) {
			 
			sMovie.startPlayback ();
		} 
	} 
	 
	//----------------------------------------------------------------// 
6
CodeRank
This code example shows how to use the following methods:getComponentName, startActivity, getPackageManager
                        true, 0, "attachment", 0, 10)) { 
            // query the package manager to see if there's a registered handler 
            //     that matches. 
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse(url), mimetype);
            ResolveInfo info = activity.getPackageManager().resolveActivity(intent,
                    PackageManager.MATCH_DEFAULT_ONLY);
            if (info != null) {
                ComponentName myName = activity.getComponentName();
                // If we resolved to ourselves, we don't want to attempt to 
                // load the url only to try and download it again. 
                if (!myName.getPackageName().equals(
                        info.activityInfo.packageName)
                        || !myName.getClassName().equals(
                                info.activityInfo.name)) {
                    // someone (other than us) knows how to handle this mime 
                    // type with this scheme, don't download. 
                    try { 
                        activity.startActivity(intent);
                        return; 

7
CodeRank
This code example shows how to use the following methods:finish, startActivity
        @Override 
        protected void onPostExecute(Account account) {
            Activity context = TwitterLoginActivity.this;
 
            // Switch to this new account 
            AccountHolder.getInstance(context).setAccount(account);
            Intent i = new Intent().setClass(context, TabWidget.class);
            context.startActivity(i);
 
            context.finish();
        } 
    } 
 
    /** 
     * Class that injects the JavaScript callback when the 2nd auth 
     * page was reached. 
     */ 
    private class MyWebViewClient extends WebViewClient {
 
        @Override 
7
CodeRank
This code example shows how to use the following methods:finish, startActivity, getClass
	public final static int THEME_Grey = 2;
	 
	public static void changeToTheme(Activity activity,int theme)
	{ 
		setsTheme(theme);
		activity.finish();
		activity.startActivity(new Intent(activity,activity.getClass()));
	} 
	 
	public static void onActivityCreateSetTheme(Activity activity)
	{ 
		switch(getsTheme()) 
		{	 
			default: 
			case THEME_DEFAULT:
				activity.setTheme(R.style.Theme_Blue);
				break; 
			case THEME_Grey:
				activity.setTheme(R.style.Theme_Grey);
				break; 
7
CodeRank
This code example shows how to use the following methods:overridePendingTransition, startActivity, getPackageName
    private static void startCameraActivity(Activity activity, String action,
            String className) {
        Intent intent = new Intent(action);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        intent.setClassName(activity.getPackageName(), className);
 
        // Keep the camera instance for a while. 
        // This avoids re-opening the camera and saves time. 
        CameraHolder.instance().keep(); 
 
        try { 
            activity.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            intent.setComponent(null);
            activity.startActivity(intent);
        } 
        activity.overridePendingTransition(NO_ANIMATION, NO_ANIMATION);
    } 
 

7
CodeRank

Related Activity startActivity Questions & Answers:

Other Activity startActivity Examples

18:	    intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
19:	        new ComponentName(this, MyWallpaperService.class));
20:	    startActivity(intent);
21:	  }
22:	}

Read More

46:					// Launching News Feed Screen
47:					Intent i = new Intent(getApplicationContext(), NewsFeedActivity.class);
48:					startActivity(i);
49:				}
50:			});
-
57:					// Launching News Feed Screen
58:					Intent i = new Intent(getApplicationContext(), FriendsActivity.class);
59:					startActivity(i);
60:				}
61:			});
-
68:					// Launching News Feed Screen
69:					Intent i = new Intent(getApplicationContext(), MessagesActivity.class);
70:					startActivity(i);
71:				}
72:			});
-
79:					// Launching News Feed Screen
80:					Intent i = new Intent(getApplicationContext(), PlacesActivity.class);
81:					startActivity(i);
82:				}
83:			});
-
90:					// Launching News Feed Screen
91:					Intent i = new Intent(getApplicationContext(), EventsActivity.class);
92:					startActivity(i);
93:				}
94:			});
-
101:					// Launching News Feed Screen
102:					Intent i = new Intent(getApplicationContext(), PhotosActivity.class);
103:					startActivity(i);
104:				}
105:			});

Read More

86:				i.putExtra("now_playing", now_playing);
87:				i.putExtra("earned", earned);
88:				startActivity(i);
89:	
90:				// close this activity

Read More

27:					// Start your app main activity
28:					Intent i = new Intent(SplashScreen.this, MainActivity.class);
29:					startActivity(i);
30:	
31:					// close this activity

Read More

8:	    // Grants access to secure content.
9:	    ...
10:	    startActivity(new Intent(context, SecureActivity.class));
11:	}
12:

Read More

4:	    Intent intent =
5:	        new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
6:	    startActivity(intent);
7:	}
8:

Read More

1:	@MediumTest
2:	public void testNextActivityWasLaunchedWithIntent() {
3:	    startActivity(mLaunchIntent, null, null);
4:	    final Button launchNextButton =
5:	            (Button) getActivity()

Read More

startActivity Method Overview
Same as startActivity(Intent, Bundle) with no options specified.
See Code Examples for other Android Activity Methods: