Java Code Examples for android.content.Intent
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
protected void externalStorageStatusChanged(){ if (!SystemUtils.isExternalStorageAvailable()) { Intent intent=new Intent(this,ExternalStorageActivity.class); startActivity(intent); } }
Example 2
public SQLiteDatabase getDatabase(String type){ SQLiteDatabase db=mDbManager.getDatabase(type); if (db == null) { Intent intent=checkData(); if (intent != null) { startActivity(intent); finish(); } } return db; }
Example 3
From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/widget/.
Source file: ShareActionProvider.java

@Override public boolean onMenuItemClick(MenuItem item){ ActivityChooserModel dataModel=ActivityChooserModel.get(mContext,mShareHistoryFileName); final int itemId=item.getItemId(); Intent launchIntent=dataModel.chooseActivity(itemId); if (launchIntent != null) { mContext.startActivity(launchIntent); } return true; }
Example 4
From project 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/.
Source file: MainActivity.java

private void forceUpdate(){ progressDialog=ProgressDialog.show(this,null," Loading. Please wait ... ",true); progressDialog.show(); Intent update=new Intent(this,UpdateWidgetService.class); update.putExtra("biz.shadowservices.PhoneBalanceWidget.forceUpdates",true); startService(update); GATracker.getInstance().trackEvent("Actions","Manual Refresh","MainActivity",0); }
Example 5
From project 4308Cirrus, under directory /tendril-cirrus/src/main/java/edu/colorado/cs/cirrus/cirrus/.
Source file: CirrusActivity.java

@Override public boolean onOptionsItemSelected(MenuItem item){ if (item.getTitle() == "Settings") { Intent intent=new Intent(this,CirrusPreferenceActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivityForResult(intent,0); return true; } return false; }
Example 6
From project 4308Cirrus, under directory /tendril-cirrus/src/main/java/edu/colorado/cs/cirrus/cirrus/.
Source file: TendrilActivity.java

@Override public void onResume(){ super.onResume(); tendril=TendrilTemplate.get(); accessToken=cirrusPrefs.getAccessToken(); if (accessToken == null) { loginMenu.setVisibility(0); mainMenu.setVisibility(8); } else { Intent intent=new Intent(this,CirrusActivity.class); startActivityForResult(intent,0); } }
Example 7
From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.
Source file: AAMain.java

/** * Runs the fetching service. Pops up with a progress dialog, so that the user knows something is happening in the background. */ private void runService(){ progressDialog=ProgressDialog.show(this,"","Loading News. Please Wait..."); progressDialog.setCancelable(true); Intent service=new Intent(); service.putExtra("background",false); service.setClass(AAMain.this,RssService.class); AAMain.this.startService(service); }
Example 8
From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.
Source file: AAMain.java

/** * Starts the settings activity when user presses "Settings" * @param menuItem - Item selected from the options menu */ @Override public boolean onOptionsItemSelected(MenuItem item){ Intent activity=new Intent(); if (item.getTitle().equals(getString(R.string.settings))) { activity.setClass(this,AASettings.class); this.startActivity(activity); return true; } else return false; }
Example 9
From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/widget/.
Source file: SearchView.java

/** * Launches an intent based on a suggestion. * @param position The index of the suggestion to create the intent from. * @param actionKey The key code of the action key that was pressed,or {@link KeyEvent#KEYCODE_UNKNOWN} if none. * @param actionMsg The message for the action key that was pressed,or <code>null</code> if none. * @return true if a successful launch, false if could not (e.g. bad position). */ private boolean launchSuggestion(int position,int actionKey,String actionMsg){ Cursor c=mSuggestionsAdapter.getCursor(); if ((c != null) && c.moveToPosition(position)) { Intent intent=createIntentFromSuggestion(c,actionKey,actionMsg); launchIntent(intent); return true; } return false; }
Example 10
From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/widget/.
Source file: SearchView.java

/** * Create and return an Intent that can launch the voice search activity for web search. */ private Intent createVoiceWebSearchIntent(Intent baseIntent,SearchableInfo searchable){ Intent voiceIntent=new Intent(baseIntent); ComponentName searchActivity=searchable.getSearchActivity(); voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,searchActivity == null ? null : searchActivity.flattenToShortString()); return voiceIntent; }
Example 11
From project adg-android, under directory /src/com/analysedesgeeks/android/.
Source file: ActivityController.java

public static void onContactEmailClicked(final Context context){ final Intent emailIntent=new Intent(android.content.Intent.ACTION_SEND); final Resources res=context.getResources(); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{Const.ADG_CONTACT_EMAIL}); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,res.getString(R.string.contactEmailSubject)); context.startActivity(Intent.createChooser(emailIntent,res.getString(R.string.sendEmail))); }
Example 12
From project adg-android, under directory /src/com/analysedesgeeks/android/.
Source file: ActivityController.java

public static void showPodcast(final Context context,final int position){ final Intent intent=new Intent(context,PodcastActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Const.EXTRA_POSITION,position); context.startActivity(intent); }
Example 13
From project agit, under directory /agit/src/main/java/com/madgag/agit/.
Source file: BlobViewerActivity.java

@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); fixImageTilingOn(getSupportActionBar()); Intent i=getIntent(); String revision=i.getStringExtra(REVISION), path=i.getStringExtra(PATH); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setActionBarTitleFor(revision,path); if (savedInstanceState == null) { BlobViewFragment details=BlobViewFragment.newInstance(gitdir(),revision,path); getSupportFragmentManager().beginTransaction().add(android.R.id.content,details).commit(); } }
Example 14
From project agit, under directory /agit/src/main/java/com/madgag/agit/.
Source file: BlobViewerActivity.java

@Override public boolean onOptionsItemSelected(MenuItem item){ switch (item.getItemId()) { case android.R.id.home: String revision=getIntent().getStringExtra(REVISION); Intent intent=AbbreviatedObjectId.isId(revision) ? commitViewIntentFor(getIntent().getExtras()).toIntent() : branchViewerIntentFor(gitdir(),revision); return homewardsWith(this,intent); } return super.onOptionsItemSelected(item); }
Example 15
From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/.
Source file: ButtonsActivity.java

private void stopAirCasting(){ if (sessionManager.getSession().isEmpty()) { Toast.makeText(context,R.string.no_data,Toast.LENGTH_SHORT).show(); sessionManager.discardSession(); } else { sessionManager.stopSession(); Intent intent=new Intent(this,SaveSessionActivity.class); startActivityForResult(intent,Intents.SAVE_DIALOG); } }
Example 16
From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/.
Source file: EditSessionActivity.java

@Override public void onClick(View view){ session.setTitle(sessionTitle.getText().toString()); session.setDescription(sessionDescription.getText().toString()); session.setTags(sessionTags.getText().toString()); Intent intent=new Intent(); intent.putExtra(Intents.SESSION,session); setResult(view.getId(),intent); finish(); }
Example 17
From project abalone-android, under directory /src/com/bytopia/abalone/.
Source file: MainMenuActivity.java

@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mainMenuActivity=this; setContentView(R.layout.menu); Button newGameButtonHuman=(Button)findViewById(R.id.n_game_human); newGameButtonHuman.setOnClickListener(new OnClickListener(){ @Override public void onClick( View v){ Intent intent=new Intent("com.bytopia.abalone.GAMEOPTIONS"); intent.putExtra("vs","human"); startActivity(intent); } } ); Button newGameButtonCpu=(Button)findViewById(R.id.n_game_cpu); newGameButtonCpu.setOnClickListener(new OnClickListener(){ @Override public void onClick( View v){ Intent intent=new Intent("com.bytopia.abalone.GAMEOPTIONS"); intent.putExtra("vs","cpu"); startActivity(intent); } } ); Button resumeButton=(Button)findViewById(R.id.resume_game); resumeButton.setOnClickListener(new OnClickListener(){ @Override public void onClick( View v){ Intent intent=new Intent("com.bytopia.abalone.RESUMEGAME"); intent.putExtra("type","resume"); startActivity(intent); } } ); Button tutorialButton=(Button)findViewById(R.id.tutorial); tutorialButton.setOnClickListener(new OnClickListener(){ @Override public void onClick( View v){ Intent intent=new Intent("com.bytopia.abalone.TUTORIAL"); startActivity(intent); } } ); }
Example 18
From project abalone-android, under directory /src/com/bytopia/abalone/.
Source file: MainMenuActivity.java

@Override public boolean onOptionsItemSelected(MenuItem item){ super.onOptionsItemSelected(item); switch (item.getItemId()) { case R.id.rules_menu: Dialog dialog=new Dialog(this); dialog.setContentView(R.layout.rules); dialog.setTitle(getString(R.string.rules_title)); dialog.show(); break; case R.id.preferences_menu: Intent preferencesIntent=new Intent("com.bytopia.abalone.PREFERENCES"); startActivity(preferencesIntent); break; } return true; }
Example 19
From project AChartEngine, under directory /client/src/org/achartengine/demo/.
Source file: Demo.java

@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.main); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.titlebar_icon); findViewById(R.id.button_multiseries_data_provider).setOnClickListener(new OnClickListener(){ public void onClick( View v){ Uri u=DataContentProvider.BASE_URI.buildUpon().appendPath(DataContentProvider.CHART_DATA_MULTISERIES_PATH).appendPath(DataContentProvider.CHART_DATA_UNLABELED_PATH).build(); Intent i=new Intent(Intent.ACTION_VIEW,u); i.putExtra(Intent.EXTRA_TITLE,TemperatureData.DEMO_CHART_TITLE); startActivity(i); } } ); findViewById(R.id.button_labeled_multiseries_data_provider).setOnClickListener(new OnClickListener(){ public void onClick( View v){ Uri u=DataContentProvider.BASE_URI.buildUpon().appendPath(DataContentProvider.CHART_DATA_MULTISERIES_PATH).appendPath(DataContentProvider.CHART_DATA_LABELED_PATH).build(); Intent i=new Intent(Intent.ACTION_VIEW,u); i.putExtra(Intent.EXTRA_TITLE,DonutData.DEMO_CHART_TITLE); startActivity(i); } } ); }
Example 20
From project AChartEngine, under directory /client/src/org/achartengine/demo/.
Source file: Demo.java

@Override public boolean onOptionsItemSelected(MenuItem item){ switch (item.getItemId()) { case R.id.menu_about: { Uri flickr_destination=Uri.parse(GOOGLE_CODE_URL); startActivity(new Intent(Intent.ACTION_VIEW,flickr_destination)); return true; } } return super.onOptionsItemSelected(item); }
Example 21
From project actionbar, under directory /actionbar-example/src/main/java/com/github/erd/actionbar/widget/.
Source file: ActionbarChooser.java

/** * {@inheritDoc} */ @Override protected void onCreate(Bundle icicle){ super.onCreate(icicle); setContentView(R.layout.activity_chooser); Button button1=(Button)findViewById(R.id.button1); button1.setOnClickListener(new View.OnClickListener(){ @Override public void onClick( View v){ startActivity(new Intent(v.getContext(),ActionbarExample1.class)); } } ); Button button2=(Button)findViewById(R.id.button2); button2.setOnClickListener(new View.OnClickListener(){ @Override public void onClick( View v){ startActivity(new Intent(v.getContext(),ActionbarExample2.class)); } } ); Button button3=(Button)findViewById(R.id.button3); button3.setOnClickListener(new View.OnClickListener(){ @Override public void onClick( View v){ startActivity(new Intent(v.getContext(),ActionbarExample3.class)); } } ); Button button4=(Button)findViewById(R.id.button4); button4.setOnClickListener(new View.OnClickListener(){ @Override public void onClick( View v){ startActivity(new Intent(v.getContext(),ActionbarExample4.class)); } } ); }