Java Code Examples for android.content.Intent#setFlags()
The following examples show how to use
android.content.Intent#setFlags() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: QuickNote File: CommonUtil.java License: Apache License 2.0 | 6 votes |
public static void shareApp(Context context, boolean isShareAppIcon) { String shareAppTip = QuickNote.getString(R.string.share_app_content); if (isShareAppIcon) { new File(context.getFilesDir(), SHARE_APP_IMAGE).deleteOnExit(); try { FileOutputStream fos = context.openFileOutput(SHARE_APP_IMAGE, Context.MODE_WORLD_READABLE); Bitmap pic = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_app); pic.compress(Bitmap.CompressFormat.JPEG, 100, fos); } catch (Exception e) { e.printStackTrace(); } } Intent intent = new Intent("android.intent.action.SEND"); intent.setType("image/*"); intent.putExtra("sms_body", shareAppTip); intent.putExtra("android.intent.extra.TEXT", shareAppTip); if (isShareAppIcon) { File shareImage = new File(context.getFilesDir(), SHARE_APP_IMAGE); if (shareImage.exists()) { intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(shareImage)); } } intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(Intent.createChooser(intent, QuickNote.getString(R.string.share_app_title))); }
Example 2
Source Project: BotLibre File: DomainActivity.java License: Eclipse Public License 1.0 | 6 votes |
public void browse(View view) { MainActivity.type = MainActivity.defaultType; MainActivity.connection.setDomain((DomainConfig)MainActivity.instance); MainActivity.domain = (DomainConfig)MainActivity.instance; MainActivity.tags = null; MainActivity.categories = null; MainActivity.forumTags = null; MainActivity.forumCategories = null; MainActivity.channelTags = null; MainActivity.channelCategories = null; MainActivity.avatarTags = null; MainActivity.avatarCategories = null; MainActivity.scriptTags = null; MainActivity.scriptCategories = null; Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); }
Example 3
Source Project: fingerpoetry-android File: CheckUpdateTask.java License: Apache License 2.0 | 6 votes |
/** * Show Notification */ private void showNotification(Context context, String content, String apkUrl) { Intent myIntent = new Intent(context, DownloadService.class); myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); myIntent.putExtra(Constants.APK_DOWNLOAD_URL, apkUrl); PendingIntent pendingIntent = PendingIntent.getService(context, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT); int smallIcon = context.getApplicationInfo().icon; Notification notify = new NotificationCompat.Builder(context) .setTicker(context.getString(R.string.android_auto_update_notify_ticker)) .setContentTitle(context.getString(R.string.android_auto_update_notify_content)) .setContentText(content) .setSmallIcon(smallIcon) .setContentIntent(pendingIntent).build(); notify.flags = Notification.FLAG_AUTO_CANCEL; NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notify); }
Example 4
Source Project: dex-hdog File: MainActivity.java License: MIT License | 6 votes |
private void openApp(String packageName) { PackageManager pm = this.getPackageManager(); Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveIntent.setPackage(packageName); List<ResolveInfo> apps = pm.queryIntentActivities(resolveIntent, 0); for (ResolveInfo app : apps) { if (packageName.equals(app.activityInfo.packageName)) { String className = app.activityInfo.name; ComponentName cn = new ComponentName(packageName, className); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setComponent(cn); startActivity(intent); } } }
Example 5
Source Project: codeexamples-android File: NotificationDisplay.java License: Eclipse Public License 1.0 | 6 votes |
public void onClick(View v) { // The user has confirmed this notification, so remove it. ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .cancel(R.layout.status_bar_notifications); // Pressing on the button brings the user back to our mood ring, // as part of the api demos app. Note the use of NEW_TASK here, // since the notification display activity is run as a separate task. Intent intent = new Intent(this, StatusBarNotifications.class); intent.setAction(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); // We're done. finish(); }
Example 6
Source Project: Birdays File: AlarmReceiver.java License: Apache License 2.0 | 5 votes |
/** * Creates intent to open DetailActivity on notification click */ private Intent getResultIntent(Context context, long timeStamp, Intent intent) { Intent resultIntent = new Intent(context, DetailActivity.class); resultIntent.putExtra(Constants.TIME_STAMP, timeStamp); if (BirdaysApplication.isActivityVisible()) { resultIntent = intent; } resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); return resultIntent; }
Example 7
Source Project: chaoli-forum-for-android-2 File: HomepageActivity.java License: GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getOrder()){ case MENU_SETTING: //startActivity(new Intent(HomepageActivity.this, SettingsActivity.class)); startActivityForResult(new Intent(HomepageActivity.this, SettingsActivity.class), SETTING_CODE); break; case MENU_LOGOUT: // showProcessDialog(getString(R.string.just_a_sec)); Toast.makeText(getApplicationContext(), R.string.logout_success, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(HomepageActivity.this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); LoginUtils.logout(new LoginUtils.LogoutObserver() { @Override public void onLogoutSuccess() { // dismissProcessDialog(); } @Override public void onLogoutFailure(int statusCode) { dismissProcessDialog(); showToast(R.string.network_err); } }); break; } return true; }
Example 8
Source Project: MissZzzReader File: AlarmHelper.java License: Apache License 2.0 | 5 votes |
public static void removeOneShotAlarm(Context context, int id){ Intent intent = new Intent(alarmActicon); intent.setFlags(FLAG_INCLUDE_STOPPED_PACKAGES); PendingIntent pi = PendingIntent.getBroadcast(context, id, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarmManager = (AlarmManager)context.getSystemService(ALARM_SERVICE); alarmManager.cancel(pi); }
Example 9
Source Project: SuntimesWidget File: AlarmNotifications.java License: GNU General Public License v3.0 | 5 votes |
public static Intent getAlarmListIntent(Context context, Long selectedAlarmId) { Intent intent = new Intent(context, AlarmClockActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (selectedAlarmId != null) { intent.setData(ContentUris.withAppendedId(AlarmClockItem.CONTENT_URI, selectedAlarmId)); intent.putExtra(AlarmClockActivity.EXTRA_SELECTED_ALARM, selectedAlarmId); } return intent; }
Example 10
Source Project: Gank.io File: ShareUtil.java License: GNU General Public License v3.0 | 5 votes |
public static void shareImage(Context context, Uri uri, String title) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpeg"); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(Intent.createChooser(shareIntent, title)); }
Example 11
Source Project: leafpicrevived File: MainActivity.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onMediaClick(Album album, ArrayList<Media> media, int position) { if (!pickMode) { Intent intent = new Intent(getApplicationContext(), SingleMediaActivity.class); intent.putExtra(SingleMediaActivity.EXTRA_ARGS_ALBUM, album); try { intent.setAction(SingleMediaActivity.ACTION_OPEN_ALBUM); intent.putExtra(SingleMediaActivity.EXTRA_ARGS_MEDIA, media); intent.putExtra(SingleMediaActivity.EXTRA_ARGS_POSITION, position); startActivity(intent); } catch (Exception e) { // Putting too much data into the Bundle // TODO: Find a better way to pass data between the activities - possibly a key to // access a HashMap or a unique value of a singleton Data Repository of some sort. intent.setAction(SingleMediaActivity.ACTION_OPEN_ALBUM_LAZY); intent.putExtra(SingleMediaActivity.EXTRA_ARGS_MEDIA, media.get(position)); startActivity(intent); } } else { Media m = media.get(position); Uri uri = LegacyCompatFileProvider.getUri(getApplicationContext(), m.getFile()); Intent res = new Intent(); res.setData(uri); res.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); setResult(RESULT_OK, res); finish(); } }
Example 12
Source Project: LyricHere File: MediaNotificationManager.java License: Apache License 2.0 | 5 votes |
private PendingIntent createContentIntent(MediaDescriptionCompat description) { Intent openUI = new Intent(mService, MusicPlayerActivity.class); openUI.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); openUI.putExtra(MusicPlayerActivity.EXTRA_START_FULLSCREEN, true); if (description != null) { openUI.putExtra(MusicPlayerActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION, description); } return PendingIntent.getActivity(mService, REQUEST_CODE, openUI, PendingIntent.FLAG_CANCEL_CURRENT); }
Example 13
Source Project: alipay-master File: App.java License: GNU General Public License v3.0 | 5 votes |
public static void dealAlipayCookieStr(Context context, Intent intent) { String cookieStr = intent.getStringExtra("cookieStr"); String toastString = cookieStr; Log.i("liunianprint:", toastString); Toast.makeText(context, toastString, Toast.LENGTH_SHORT).show(); Intent startIntent = new Intent(context, MainActivity.class); startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(startIntent); }
Example 14
Source Project: dhis2-android-capture-app File: SyncActivity.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
public void startMain() { getSharedPreferences().edit().putBoolean(Preference.INITIAL_SYNC_DONE, true).apply(); Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); }
Example 15
Source Project: ResearchStack File: OnboardingActivity.java License: Apache License 2.0 | 5 votes |
private void startMainActivity() { // Onboarding completion is checked in splash activity. The check allows us to pass through // to MainActivity even if we haven't signed in. We want to set this true in every case so // the user is really only forced through Onboarding once. If they leave the study, they must // re-enroll in Settings, which starts OnboardingActivty. AppPrefs.getInstance(this).setOnboardingComplete(true); // Start MainActivity w/ clear_top and single_top flags. MainActivity may // already be on the activity-task. We want to re-use that activity instead // of creating a new instance and have two instance active. Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); finish(); }
Example 16
Source Project: matomo-sdk-android File: DemoActivity.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { Intent intent = new Intent(this, SettingsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
Example 17
Source Project: alpha-wallet-android File: TransferTicketDetailRouter.java License: MIT License | 5 votes |
public void openTransfer(Context context, Token token, String ticketIDs, Wallet wallet, int state) { Intent intent = new Intent(context, TransferTicketDetailActivity.class); intent.putExtra(C.Key.WALLET, wallet); intent.putExtra(C.Key.TICKET, token); intent.putExtra(C.EXTRA_TOKENID_LIST, ticketIDs); intent.putExtra(C.EXTRA_STATE, state); intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); context.startActivity(intent); }
Example 18
Source Project: freemp File: ServicePlayer.java License: Apache License 2.0 | 4 votes |
@Override public void onCreate() { super.onCreate(); // initialize default output device if (!BASS.BASS_Init(-1, 44100, 0)) { return; } // look for plugins plugins = ""; String path = getApplicationInfo().nativeLibraryDir; String[] list = new File(path).list(); for (String s : list) { int plug = BASS.BASS_PluginLoad(path + "/" + s, 0); if (plug != 0) { // plugin loaded... plugins += s + "\n"; // add it to the list } } if (plugins.equals("")) plugins = "no plugins - visit the BASS webpage to get some\n"; if (activity != null) { activity.onPluginsLoaded(plugins); } BASS.BASS_SetConfig(BASS.BASS_CONFIG_BUFFER, 1000); Log.w("BASS.BASS_CONFIG_BUFFER", "" + BASS.BASS_GetConfig(BASS.BASS_CONFIG_BUFFER)); //screen screenHeight = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("screenHeight", 1000); screenWidth = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("screenWidth", 800); // Pending Intend Intent intent = new Intent(this, ActPlayer.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); pendIntent = PendingIntent.getActivity(this, 0, intent, 0); //tracklist updateTrackList(); tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tm.listen(telephone, PhoneStateListener.LISTEN_CALL_STATE); myBroadcastReceiver = new MyBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG); intentFilter.addAction("android.media.VOLUME_CHANGED_ACTION"); intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED); registerReceiver(myBroadcastReceiver, intentFilter); mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); ComponentName rcvMedia = new ComponentName(getPackageName(), RcvMediaControl.class.getName()); mAudioManager.registerMediaButtonEventReceiver(rcvMedia); // Use the remote control APIs (if available) to set the playback state if (android.os.Build.VERSION.SDK_INT >= 14 && remoteControlClient == null) { registerRemoteControl(rcvMedia); } }
Example 19
Source Project: adamant-android File: AdamantFirebaseMessagingService.java License: GNU General Public License v3.0 | 4 votes |
private void showNotification(String title, String message) { String channelId = buildChannel(); Intent notificationIntent = new Intent(this.getApplicationContext(), SplashScreen.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntent, 0); Notification notification = NotificationHelper.buildMessageNotification(channelId, this, title, message); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notification.contentIntent = intent; notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(NOTIFICATION_ID, notification); }
Example 20
Source Project: imsdk-android File: NativeApi.java License: MIT License | 4 votes |
public static void openPublicNumberVC() { Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(CommonConfig.schema + "://qunarchat/search?" + SEARCH_SCOPE + "=4")); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); CommonConfig.globalContext.startActivity(intent); }