List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:org.onebusaway.android.ui.TripPlanActivity.java
@Override public void onTripRequestComplete(List<Itinerary> itineraries, String url) { // Send intent to ourselves... Intent intent = new Intent(this, TripPlanActivity.class).setAction(Intent.ACTION_MAIN) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) .putExtra(OTPConstants.ITINERARIES, (ArrayList<Itinerary>) itineraries) .putExtra(OTPConstants.INTENT_SOURCE, OTPConstants.Source.ACTIVITY).putExtra(PLAN_REQUEST_URL, url); startActivity(intent);/*w w w. j a v a 2 s .c o m*/ }
From source file:com.farmerbb.secondscreen.util.U.java
public static String uiRefreshCommand2(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); // For better reliability, we execute the UI refresh while on the home screen Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.addCategory(Intent.CATEGORY_DEFAULT); homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(homeIntent);/*from w w w .ja va 2 s .c om*/ // Kill all background processes, in order to fully refresh UI PackageManager pm = context.getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(0); for (ApplicationInfo packageInfo : packages) { if (!packageInfo.packageName.equalsIgnoreCase(context.getPackageName())) am.killBackgroundProcesses(packageInfo.packageName); } // Get launcher package name final ResolveInfo mInfo = pm.resolveActivity(homeIntent, 0); return "sleep 1 && am force-stop " + mInfo.activityInfo.applicationInfo.packageName; }
From source file:edu.chalmers.dat255.audiobookplayer.view.MainActivity.java
@Override public void onBackPressed() { super.onBackPressed(); Log.i(TAG, "Back pressed in Main Activity"); Intent intent = new Intent(Intent.ACTION_MAIN); // move to the home screen when pressing back intent.addCategory(Intent.CATEGORY_HOME); // start a new task intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);/*from w w w . j ava 2 s .c o m*/ }
From source file:com.nachiket.titan.LibraryActivity.java
/** * If this intent looks like a launch from icon/widget/etc, perform * launch actions.//from w ww.jav a2 s. c o m */ private void checkForLaunch(Intent intent) { SharedPreferences settings = PlaybackService.getSettings(this); if (settings.getBoolean(PrefKeys.PLAYBACK_ON_STARTUP, false) && Intent.ACTION_MAIN.equals(intent.getAction())) { startActivity(new Intent(this, FullPlaybackActivity.class)); } }
From source file:cl.iluminadoschile.pako.floatingdiv.CustomOverlayService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null || null == intent.getAction()) { Log.i(LOG_TAG, "Received null Foreground Intent "); if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { if (activation_method.equals(Constants.SETTINGS.ACTIVATION_METHOD_ALONGWITHINGRESS)) { startMonitorIngressRunning(); }/*from w w w .j a v a 2s . co m*/ } } else if (intent.getAction().equals(Constants.ACTION.STARTFOREGROUND_ACTION)) { Log.i(LOG_TAG, "Received Start Foreground Intent "); overlayView.setVisible(); if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { if (activation_method.equals(Constants.SETTINGS.ACTIVATION_METHOD_ALONGWITHINGRESS)) { startMonitorIngressRunning(); } } } else if (intent.getAction().equals(Constants.ACTION.SETTINGS_ACTION)) { Log.i(LOG_TAG, "Received Settings Intent"); Intent settingsIntent = new Intent(Intent.ACTION_MAIN); settingsIntent.setClassName(Constants.ACTION.prefix, Constants.ACTION.prefix + ".SettingsActivity"); settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(settingsIntent); } else if (intent.getAction().equals(Constants.ACTION.PAUSEFOREGROUND_ACTION)) { Log.i(LOG_TAG, "Received Pause Foreground Intent"); overlayView.setInvisible(); } else if (intent.getAction().equals(Constants.ACTION.STOPFOREGROUND_ACTION)) { Log.i(LOG_TAG, "Received Stop Foreground Intent"); overlayView.setInvisible(); stopForeground(true); stopSelf(); } return START_STICKY; }
From source file:org.onebusaway.android.ui.TripPlanActivity.java
@Override public void onTripRequestFailure(int errorCode, String url) { Intent intent = new Intent(this, TripPlanActivity.class).setAction(Intent.ACTION_MAIN) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP).putExtra(PLAN_ERROR_CODE, errorCode) .putExtra(PLAN_ERROR_URL, url).putExtra(OTPConstants.INTENT_SOURCE, OTPConstants.Source.ACTIVITY); startActivity(intent);//from ww w . jav a 2s .co m }
From source file:info.papdt.blacklight.ui.statuses.SingleActivity.java
@Binded public void commentOn() { Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); i.setClass(this, CommentOnActivity.class); i.putExtra("msg", mMsg); startActivity(i);/*from ww w .j ava 2 s . c o m*/ }
From source file:org.noise_planet.noisecapture.MainActivity.java
@Override public void onBackPressed() { if (!(this instanceof MeasurementActivity)) { if (mDrawerLayout != null) { mDrawerLayout.closeDrawer(mDrawerList); }//from w ww . j a v a2s . com Intent im = new Intent(getApplicationContext(), MeasurementActivity.class); im.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(im); finish(); } else { finish(); // Show home Intent im = new Intent(Intent.ACTION_MAIN); im.addCategory(Intent.CATEGORY_HOME); im.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(im); } }
From source file:org.wso2.app.catalog.api.ApplicationManager.java
/** * Checks whether the DownloadManager is available on the device. * * @param context - Context of the calling activity. *//*from ww w . j a v a2s.co m*/ public boolean isDownloadManagerAvailable(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName(resources.getString(R.string.android_download_manager_ui_resolver), resources.getString(R.string.android_download_manager_list_resolver)); return context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY) .size() > 0; }
From source file:com.pdmanager.views.caregiver.CaregiverActivity.java
@Override public void onMessageReceived(final CNMessage cnMessage) { if (application.getUniqueId().equals(cnMessage.getUniqueId())) { return;//from w w w. jav a 2 s . c o m } if (cnMessage.getMessageType() == CNMessage.CNMessageType.Calling) { if (application.isInConference()) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.Busy, null); return; } callDialog = new AlertDialog.Builder(this).create(); LayoutInflater inflater = getLayoutInflater(); View incomingCallDialog = inflater.inflate(R.layout.incoming_call_dialog, null); incomingCallDialog.setAlpha(0.5f); callDialog.setView(incomingCallDialog); TextView caller = (TextView) incomingCallDialog.findViewById(R.id.caller); caller.setText(cnMessage.getDisplayName()); Button answerButton = (Button) incomingCallDialog.findViewById(R.id.answer_button); answerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.setConferenceId(cnMessage.getConferenceId()); application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerAccept, null); callDialog.hide(); currentRingtone.stop(); Intent intent = new Intent(application.getContext(), CaregiverActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intent); application.join(application.getConferenceId(), true); } }); Button declineButton = (Button) incomingCallDialog.findViewById(R.id.decline_button); declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerDecline, null); currentRingtone.stop(); callDialog.hide(); } }); callDialog.setCancelable(false); callDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //play current Ringtone currentRingtone.play(); callDialog.show(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.Cancel) { currentRingtone.stop(); callDialog.hide(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.EndCall) { if (application.leave()) { int count = getFragmentManager().getBackStackEntryCount(); String name = getFragmentManager().getBackStackEntryAt(count - 2).getName(); getFragmentManager().popBackStack(name, FragmentManager.POP_BACK_STACK_INCLUSIVE); } } }