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.cpic.taylor.logistics.activity.HomeActivity.java
@Override public void onBackPressed() { // // ? // long currentTime = System.currentTimeMillis(); // long dTime = currentTime - lastTime; ///*from w w w . j a va2 s. c o m*/ // if (dTime < 2000) { // finish(); // } else { // showShortToast("??"); // lastTime = currentTime; // } Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);// ? intent.addCategory(Intent.CATEGORY_HOME); this.startActivity(intent); }
From source file:com.birdeye.MainActivity.java
@OnClick(R.id.apply) void onClick() {//from ww w . j a v a 2 s .com if (Globals.hasPaid) { Prefs.usernames.set(TextViews.trimmed(usernames)); Prefs.hashtags.set(TextViews.trimmed(hashtags)); Prefs.message1.set(TextViews.trimmed(message1)); Prefs.message2.set(TextViews.trimmed(message2)); Prefs.message3.set(TextViews.trimmed(message3)); Prefs.message4.set(TextViews.trimmed(message4)); Prefs.message5.set(TextViews.trimmed(message5)); Prefs.message6.set(TextViews.trimmed(message6)); Prefs.message7.set(TextViews.trimmed(message7)); Prefs.message8.set(TextViews.trimmed(message8)); Prefs.message9.set(TextViews.trimmed(message9)); Prefs.message10.set(TextViews.trimmed(message10)); Prefs.message11.set(TextViews.trimmed(message11)); Prefs.message12.set(TextViews.trimmed(message12)); Prefs.message13.set(TextViews.trimmed(message13)); Prefs.message14.set(TextViews.trimmed(message14)); Prefs.message15.set(TextViews.trimmed(message15)); Prefs.message16.set(TextViews.trimmed(message16)); Prefs.message17.set(TextViews.trimmed(message17)); Prefs.message18.set(TextViews.trimmed(message18)); Prefs.message19.set(TextViews.trimmed(message19)); Prefs.message20.set(TextViews.trimmed(message20)); Prefs.message21.set(TextViews.trimmed(message21)); Prefs.message22.set(TextViews.trimmed(message22)); Prefs.message23.set(TextViews.trimmed(message23)); Prefs.message24.set(TextViews.trimmed(message24)); Prefs.message25.set(TextViews.trimmed(message25)); } else { Prefs.usernames.set(TextViews.trimmed(usernames)); Prefs.hashtags.set(TextViews.trimmed(hashtags)); Prefs.message1.set(TextViews.trimmed(message1)); Prefs.message2.set(TextViews.trimmed(message2)); Prefs.message3.set(TextViews.trimmed(message3)); } if (canEnable()) { textLayout(usernames).setError(null); textLayout(usernames).setErrorEnabled(false); textLayout(hashtags).setError(null); textLayout(hashtags).setErrorEnabled(false); Realm.getDefaultInstance().executeTransactionAsync(realm -> { final RealmResults<LocalTweet> tweets = realm.where(LocalTweet.class).equalTo("replied", false) .findAll(); for (LocalTweet replied : tweets) { replied.deleteFromRealm(); } }); Prefs.lastId.set(null); //noinspection ConstantConditions if (Prefs.enable.get()) { final Intent svc = EyeService.create(this); stopService(svc); startService(svc); startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } } else { final String err = getString(R.string.at_least_one_user); textLayout(usernames).setError(err); textLayout(hashtags).setError(err); Prefs.enable.set(false); initial(false); } }
From source file:nl.mpcjanssen.simpletask.AddTask.java
private void setupShortcut() { Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(this, this.getClass().getName()); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcut_addtask_name)); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); setResult(RESULT_OK, intent);/*from w w w .j ava2 s . c o m*/ }
From source file:com.facebook.SessionTests.java
@SmallTest @MediumTest//from w w w . j a v a 2s. c o m @LargeTest public void testOpenSessionWithNativeLinkingIntent() { String token = "A token less unique than most"; Intent intent = new Intent(Intent.ACTION_MAIN); intent.putExtras(getNativeLinkingExtras(token)); SessionStatusCallbackRecorder statusRecorder = new SessionStatusCallbackRecorder(); MockTokenCachingStrategy cache = new MockTokenCachingStrategy(null, DEFAULT_TIMEOUT_MILLISECONDS); ScriptedSession session = createScriptedSessionOnBlockerThread(cache); assertEquals(SessionState.CREATED, session.getState()); AccessToken accessToken = AccessToken.createFromNativeLinkingIntent(intent); assertNotNull(accessToken); session.open(accessToken, statusRecorder); statusRecorder.waitForCall(session, SessionState.OPENED, null); assertEquals(token, session.getAccessToken()); // Expiration time should be 3600s after now (allow 5s variation for test execution time) long delta = session.getExpirationDate().getTime() - new Date().getTime(); assertTrue(Math.abs(delta - 3600 * 1000) < 5000); assertEquals(0, session.getPermissions().size()); assertEquals(Utility.getMetadataApplicationId(getActivity()), session.getApplicationId()); // Verify we get a close callback. session.close(); statusRecorder.waitForCall(session, SessionState.CLOSED, null); assertFalse(cache.getSavedState() == null); // Wait a bit so we can fail if any unexpected calls arrive on the // recorder. stall(STRAY_CALLBACK_WAIT_MILLISECONDS); statusRecorder.close(); }
From source file:org.mariotaku.twidere.provider.TwidereDataProvider.java
private void displayMessagesNotification(final Context context, final ContentValues[] values) { final Resources res = context.getResources(); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context); final boolean display_screen_name = NAME_DISPLAY_OPTION_SCREEN_NAME .equals(mPreferences.getString(PREFERENCE_KEY_NAME_DISPLAY_OPTION, NAME_DISPLAY_OPTION_BOTH)); final boolean display_hires_profile_image = res.getBoolean(R.bool.hires_profile_image); final Intent delete_intent = new Intent(BROADCAST_NOTIFICATION_CLEARED); final Bundle delete_extras = new Bundle(); delete_extras.putInt(INTENT_KEY_NOTIFICATION_ID, NOTIFICATION_ID_DIRECT_MESSAGES); delete_intent.putExtras(delete_extras); final Intent content_intent; int notified_count = 0; for (final ContentValues value : values) { final String screen_name = value.getAsString(DirectMessages.SENDER_SCREEN_NAME); final ParcelableDirectMessage message = new ParcelableDirectMessage(value); mNewMessages.add(message);//w ww . j a va 2 s.c om mNewMessageScreenNames.add(screen_name); mNewMessageAccounts.add(message.account_id); notified_count++; } Collections.sort(mNewMessages); final int messages_size = mNewMessages.size(); if (notified_count == 0 || messages_size == 0 || mNewMessageScreenNames.size() == 0) return; final String title; if (messages_size > 1) { builder.setNumber(messages_size); } final int screen_names_size = mNewMessageScreenNames.size(); final ParcelableDirectMessage message = mNewMessages.get(0); if (messages_size == 1) { final Uri.Builder uri_builder = new Uri.Builder(); final long account_id = message.account_id; final long conversation_id = message.sender_id; uri_builder.scheme(SCHEME_TWIDERE); uri_builder.authority(AUTHORITY_DIRECT_MESSAGES_CONVERSATION); uri_builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id)); uri_builder.appendQueryParameter(QUERY_PARAM_CONVERSATION_ID, String.valueOf(conversation_id)); content_intent = new Intent(Intent.ACTION_VIEW, uri_builder.build()); } else { content_intent = new Intent(context, HomeActivity.class); content_intent.setAction(Intent.ACTION_MAIN); content_intent.addCategory(Intent.CATEGORY_LAUNCHER); final Bundle content_extras = new Bundle(); content_extras.putInt(INTENT_KEY_INITIAL_TAB, HomeActivity.TAB_POSITION_MESSAGES); content_intent.putExtras(content_extras); } if (screen_names_size > 1) { title = res.getString(R.string.notification_direct_message_multiple, display_screen_name ? "@" + message.sender_screen_name : message.sender_name, screen_names_size - 1); } else { title = res.getString(R.string.notification_direct_message, display_screen_name ? "@" + message.sender_screen_name : message.sender_name); } final String text_plain = message.text_plain; final String profile_image_url_string = message.sender_profile_image_url_string; final File profile_image_file = mProfileImageLoader.getCachedImageFile( display_hires_profile_image ? getBiggerTwitterProfileImage(profile_image_url_string) : profile_image_url_string); final int w = res.getDimensionPixelSize(R.dimen.notification_large_icon_width); final int h = res.getDimensionPixelSize(R.dimen.notification_large_icon_height); final Bitmap profile_image = profile_image_file != null && profile_image_file.isFile() ? BitmapFactory.decodeFile(profile_image_file.getPath()) : null; final Bitmap profile_image_fallback = BitmapFactory.decodeResource(res, R.drawable.ic_profile_image_default); builder.setLargeIcon(Bitmap .createScaledBitmap(profile_image != null ? profile_image : profile_image_fallback, w, h, true)); buildNotification(builder, title, title, text_plain, R.drawable.ic_stat_direct_message, null, content_intent, delete_intent); final StringBuilder summary = new StringBuilder(); final int accounts_count = mNewMessageAccounts.size(); if (accounts_count > 0) { for (int i = 0; i < accounts_count; i++) { final String name = display_screen_name ? "@" + getAccountScreenName(context, mNewMessageAccounts.get(i)) : getAccountName(context, mNewMessageAccounts.get(i)); summary.append(name); if (i != accounts_count - 1) { summary.append(", "); } } } if (messages_size > 1) { final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(builder); final int max = Math.min(4, messages_size); for (int i = 0; i < max; i++) { final ParcelableDirectMessage s = mNewMessages.get(i); final String name = display_screen_name ? "@" + s.sender_screen_name : s.sender_name; style.addLine(Html.fromHtml("<b>" + name + "</b>: " + s.text_plain)); } if (max == 4 && messages_size - max > 0) { style.addLine(context.getString(R.string.and_more, messages_size - max)); } style.setSummaryText(summary); mNotificationManager.notify(NOTIFICATION_ID_DIRECT_MESSAGES, style.build()); } else { final NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle(builder); style.bigText(message.text_plain); style.setSummaryText(summary); mNotificationManager.notify(NOTIFICATION_ID_DIRECT_MESSAGES, style.build()); } }
From source file:com.wheelphone.remotemini.WheelphoneRemoteMini.java
public void onBackPressed() { Intent setIntent = new Intent(Intent.ACTION_MAIN); setIntent.addCategory(Intent.CATEGORY_HOME); setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(setIntent);//from w w w. j av a 2 s . c o m }
From source file:com.facebook.SessionTests.java
@SmallTest @MediumTest/* ww w. j a v a 2s. co m*/ @LargeTest public void testOpenActiveSessionWithNativeLinkingIntent() { Session activeSession = Session.getActiveSession(); if (activeSession != null) { activeSession.closeAndClearTokenInformation(); } SharedPreferencesTokenCachingStrategy tokenCache = new SharedPreferencesTokenCachingStrategy(getActivity()); assertEquals(0, tokenCache.load().size()); String token = "A token less unique than most"; Intent intent = new Intent(Intent.ACTION_MAIN); intent.putExtras(getNativeLinkingExtras(token)); SessionStatusCallbackRecorder statusRecorder = new SessionStatusCallbackRecorder(); AccessToken accessToken = AccessToken.createFromNativeLinkingIntent(intent); assertNotNull(accessToken); Session session = Session.openActiveSessionWithAccessToken(getActivity(), accessToken, statusRecorder); assertEquals(session, Session.getActiveSession()); statusRecorder.waitForCall(session, SessionState.OPENED, null); assertNotSame(0, tokenCache.load().size()); assertEquals(token, session.getAccessToken()); // Expiration time should be 3600s after now (allow 5s variation for test execution time) long delta = session.getExpirationDate().getTime() - new Date().getTime(); assertTrue(Math.abs(delta - 3600 * 1000) < 5000); assertEquals(0, session.getPermissions().size()); assertEquals(Utility.getMetadataApplicationId(getActivity()), session.getApplicationId()); // Verify we get a close callback. session.close(); statusRecorder.waitForCall(session, SessionState.CLOSED, null); // Wait a bit so we can fail if any unexpected calls arrive on the // recorder. stall(STRAY_CALLBACK_WAIT_MILLISECONDS); statusRecorder.close(); }
From source file:org.musicmod.android.app.MusicPlaybackActivity.java
@Override public void onServiceConnected(ComponentName classname, IBinder obj) { mService = IMusicPlaybackService.Stub.asInterface(obj); try {//from w ww. j a v a2 s. c o m if (mService.getAudioId() >= 0 || mService.isPlaying() || mService.getPath() != null) { updateTrackInfo(false); long next = refreshNow(); queueNextRefresh(next); setPauseButtonImage(); setFavoriteButton(); mVisualizer = VisualizerWrapper.getInstance(mService.getAudioSessionId(), 50); mDisplayVisualizer = mPrefs.getBooleanState(KEY_DISPLAY_VISUALIZER, true); boolean mFftEnabled = String.valueOf(VISUALIZER_TYPE_FFT_SPECTRUM) .equals(mPrefs.getStringPref(KEY_VISUALIZER_TYPE, "1")); boolean mWaveEnabled = String.valueOf(VISUALIZER_TYPE_WAVE_FORM) .equals(mPrefs.getStringPref(KEY_VISUALIZER_TYPE, "1")); mVisualizerView.removeAllViews(); if (mFftEnabled) mVisualizerView.addView(mVisualizerViewFftSpectrum); if (mWaveEnabled) mVisualizerView.addView(mVisualizerViewWaveForm); mVisualizer.setFftEnabled(mFftEnabled); mVisualizer.setWaveFormEnabled(mWaveEnabled); mVisualizer.setOnDataChangedListener(mDataChangedListener); setVisualizerView(); } else { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClass(getApplicationContext(), MusicBrowserActivity.class); startActivity(intent); finish(); } } catch (RemoteException e) { e.printStackTrace(); } }
From source file:com.tt.jobtracker.MainActivity.java
@Override public void onBackPressed() { if (Shared.onbackpress == true) { if (back_pressed + 2000 > System.currentTimeMillis()) { // super.onBackPressed(); Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain);/*from w w w.java2s . c o m*/ } else { Toast.makeText(getBaseContext(), "Press once again to exit!", Toast.LENGTH_SHORT).show(); back_pressed = System.currentTimeMillis(); } } else { super.onBackPressed(); } }
From source file:net.ustyugov.jtalk.service.JTalkService.java
@Override public void onCreate() { configure();/*w ww . j a v a2 s . c om*/ js = this; prefs = PreferenceManager.getDefaultSharedPreferences(this); iconPicker = new IconPicker(this); // updateReceiver = new BroadcastReceiver() { // @Override // public void onReceive(Context arg0, Intent arg1) { // updateWidget(); // } // }; // registerReceiver(updateReceiver, new IntentFilter(Constants.UPDATE)); connectionReceiver = new ChangeConnectionReceiver(); registerReceiver(connectionReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); screenStateReceiver = new ScreenStateReceiver(); registerReceiver(new ScreenStateReceiver(), new IntentFilter(Intent.ACTION_SCREEN_ON)); registerReceiver(new ScreenStateReceiver(), new IntentFilter(Intent.ACTION_SCREEN_OFF)); Intent i = new Intent(this, RosterActivity.class); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_LAUNCHER); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); mBuilder.setSmallIcon(R.drawable.stat_offline); mBuilder.setContentTitle(getString(R.string.app_name)); mBuilder.setContentIntent(contentIntent); startForeground(Notify.NOTIFICATION, mBuilder.build()); WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "jTalk"); PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "jTalk"); started = true; Cursor cursor = getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { connect(); cursor.close(); } }