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:com.chale22.ico01.fragments.FragmentExtras.java
private void actRequest() { String pkg = getResources().getString(R.string.pkg); Intent iconrequest = new Intent(Intent.ACTION_MAIN); iconrequest.setComponent(new ComponentName(pkg, pkg + ".IconRequest")); try {// w w w . j a v a2 s .co m startActivity(iconrequest); } catch (RuntimeException icons) { icons.printStackTrace(); } }
From source file:ie.ucd.www.bee.MainActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == INTERNET_REQUEST_CODE || requestCode == ACCESS_NETWORK_STATE_REQUEST_CODE) if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Permission Granted } else {//from w w w . j a v a 2 s . co m // Permission Denied new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE).setTitleText("Warning") .setContentText("You must authorize BeeBia the necessary permissions.") .setConfirmText("Exit") .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sweetAlertDialog) { sweetAlertDialog.dismissWithAnimation(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }).show(); } super.onRequestPermissionsResult(requestCode, permissions, grantResults); }
From source file:com.miz.service.MakeAvailableOffline.java
@Override protected void onHandleIntent(Intent intent) { reset();//from w w w .ja v a 2s . co m LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("mizuu-stop-offline-download")); mContext = getApplicationContext(); String defaultSize = mContext.getString(R.string._16kb); String bufferSize = PreferenceManager.getDefaultSharedPreferences(mContext).getString(BUFFER_SIZE, defaultSize); if (bufferSize.equals(defaultSize)) mBufferSize = 8192 * 2; // This appears to be the limit for most video players else mBufferSize = 8192; mFileUrl = intent.getExtras().getString(FILEPATH); mType = intent.getExtras().getInt(TYPE); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // Set up cancel dialog intent Intent notificationIntent = new Intent(this, CancelOfflineDownload.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); mContentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(mContext); mBuilder.setColor(getResources().getColor(R.color.color_primary)); mBuilder.setOngoing(true); mBuilder.setOnlyAlertOnce(true); mBuilder.setSmallIcon(android.R.drawable.stat_sys_download); mBuilder.setContentIntent(mContentIntent); String message = getString(R.string.downloadingMovie); if (mType == MizLib.TYPE_SHOWS) message = getString(R.string.downloadingEpisode); mBuilder.setTicker(message); mBuilder.setContentTitle(message); mBuilder.setContentText(getContentText()); try { int size = MizLib.getThumbnailNotificationSize(mContext); mBuilder.setLargeIcon(MizuuApplication.getPicasso(mContext).load(intent.getExtras().getString("thumb")) .resize(size, (int) (size * 1.5)).get()); } catch (IOException ignored) { } try { int width = MizLib.getLargeNotificationWidth(mContext); int height = (int) (width / 1.78); mBuilder.setStyle(new NotificationCompat.BigPictureStyle().setSummaryText(message) .bigPicture(MizuuApplication.getPicasso(getApplicationContext()) .load(intent.getExtras().getString("backdrop")).resize(width, height).get())); } catch (IOException e) { } mBuilder.addAction(R.drawable.ic_close_white_24dp, getString(android.R.string.cancel), mContentIntent); boolean exists = checkIfNetworkFileExists(); if (!exists) { mHandler.post(new Runnable() { @Override public void run() { Toast.makeText(mContext, R.string.unavailable_file, Toast.LENGTH_LONG).show(); } }); stopSelf(); return; } boolean ignoreSizeCheck = PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean(IGNORE_FILESIZE_CHECK, false); if (!ignoreSizeCheck) { boolean sizeOK = checkFilesize(); if (!sizeOK) { mHandler.post(new Runnable() { @Override public void run() { Toast.makeText(mContext, R.string.not_enough_space, Toast.LENGTH_LONG).show(); } }); stopSelf(); return; } } exists = checkIfLocalCopyExists(); if (exists) { // There's already an exact local copy - don't download again stopSelf(); return; } mHandler.post(new Runnable() { @Override public void run() { Toast.makeText(mContext, R.string.starting_download, Toast.LENGTH_SHORT).show(); } }); updateNotification(); startForeground(NOTIFICATION_ID, mNotification); boolean success = beginTransfer(); if (!success) { // Delete the offline file if the transfer wasn't successful if (mFileUrl.startsWith("http")) FileUtils.getOfflineFile(mContext, mFileUrl).delete(); else FileUtils.getOfflineFile(mContext, mSmb.getCanonicalPath()).delete(); } }
From source file:com.playpalgames.app.GcmIntentService.java
private void sendNotification(String notificationMessage, String command) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(this.getApplicationContext(), StartActivity_.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.putExtra("COMMAND", command); intent.setAction(Long.toString(System.currentTimeMillis())); PendingIntent contentIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ball) .setContentTitle("Penalty!").setAutoCancel(true) .setStyle(new NotificationCompat.BigTextStyle().bigText(notificationMessage)) .setContentText(notificationMessage); mBuilder.setContentIntent(contentIntent); Notification note = mBuilder.build(); note.defaults |= Notification.DEFAULT_VIBRATE; note.defaults |= Notification.DEFAULT_SOUND; mNotificationManager.notify(NOTIFICATION_ID, note); }
From source file:com.oakesville.mythling.MainActivity.java
public void onBackPressed() { if (EpgActivity.class.getName().equals(backTo) || FireTvEpgActivity.class.getName().equals(backTo)) { Intent a = new Intent(Intent.ACTION_MAIN); a.addCategory(Intent.CATEGORY_HOME); a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(a);//from w ww. j a v a2 s. c o m } else { super.onBackPressed(); } }
From source file:com.example.RITW.proximity.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel //final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { // mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);/*from w w w . j av a 2s . co m*/ // mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } /*mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); try { startActivity(action); } catch (final ActivityNotFoundException e) { Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show(); } mDrawerLayout.closeDrawers(); } });*/ // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:kinsleykajiva.co.zw.cutstudentapp.Settinngs.java
private void removeShortCut() { Intent shortcutInt = new Intent(getApplicationContext(), Settinngs.class); shortcutInt.setAction(Intent.ACTION_MAIN); Intent addInt = new Intent(); addInt.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutInt); addInt.putExtra(Intent.EXTRA_SHORTCUT_NAME, "C.U.T Student"); addInt.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); getApplicationContext().sendBroadcast(addInt); }
From source file:hku.fyp14017.blencode.utils.StatusBarNotificationManager.java
public int createDownloadNotification(Context context, String programName) { if (context == null || programName == null) { return -1; }//from ww w . ja va 2 s . c o m initNotificationManager(context); Intent downloadIntent = new Intent(context, MainMenuActivity.class); downloadIntent.setAction(Intent.ACTION_MAIN).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) .putExtra(EXTRA_PROJECT_NAME, programName); PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationId, downloadIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationData data = new NotificationData(context, pendingIntent, hku.fyp14017.blencode.R.drawable.ic_stat, programName, hku.fyp14017.blencode.R.string.notification_download_title_pending, hku.fyp14017.blencode.R.string.notification_title_open, hku.fyp14017.blencode.R.string.notification_download_pending, hku.fyp14017.blencode.R.string.notification_download_finished); return createNotification(context, data); }
From source file:org.jonblack.bluetrack.activities.MainActivity.java
/** * Do not let the back key call finish on our activity. *///from ww w . j a v a 2s. c o m @Override public void onBackPressed() { Log.d(TAG, "onBackPressed Called"); Intent setIntent = new Intent(Intent.ACTION_MAIN); setIntent.addCategory(Intent.CATEGORY_HOME); setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(setIntent); }
From source file:com.amaze.carbonfilemanager.services.CopyService.java
@Override public int onStartCommand(Intent intent, int flags, final int startId) { Bundle b = new Bundle(); ArrayList<BaseFile> files = intent.getParcelableArrayListExtra(TAG_COPY_SOURCES); String targetPath = intent.getStringExtra(TAG_COPY_TARGET); int mode = intent.getIntExtra(TAG_COPY_OPEN_MODE, OpenMode.UNKNOWN.ordinal()); final boolean move = intent.getBooleanExtra(TAG_COPY_MOVE, false); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); b.putInt(TAG_COPY_START_ID, startId); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(c); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.copying)) .setSmallIcon(R.drawable.ic_content_copy_white_36dp); startForeground(Integer.parseInt("456" + startId), mBuilder.build()); b.putBoolean(TAG_COPY_MOVE, move);/*from w w w . j av a 2s .c o m*/ b.putString(TAG_COPY_TARGET, targetPath); b.putInt(TAG_COPY_OPEN_MODE, mode); b.putParcelableArrayList(TAG_COPY_SOURCES, files); //going async new DoInBackground().execute(b); // If we get killed, after returning from here, restart return START_STICKY; }