android.content.Intent Java Examples
The following examples show how to use
android.content.Intent.
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 File: SwipeLayoutActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_listview) { startActivity(new Intent(this, ListViewExample.class)); return true; } else if (id == R.id.action_gridview) { startActivity(new Intent(this, GridViewExample.class)); return true; } else if (id == R.id.action_nexted) { startActivity(new Intent(this, NestedExample.class)); return true; } return super.onOptionsItemSelected(item); }
Example #2
Source File: AlarmLayout.java From talalarmo with MIT License | 5 votes |
private static void showSettingsMenu(View v) { PopupMenu menu = new PopupMenu(v.getContext(), v); menu.getMenuInflater().inflate(R.menu.overflow_popup, menu.getMenu()); menu.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.menu_settings) { ((MainActivity) v.getContext()).openSettings(); } else if (item.getItemId() == R.id.menu_feedback) { Context c = v.getContext(); Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "[email protected]", null)); intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback about Talalarmo"); v.getContext().startActivity(Intent.createChooser(intent, c.getString(R.string.leave_feedback))); } return true; }); menu.show(); }
Example #3
Source File: NativeProtocol.java From Abelana-Android with Apache License 2.0 | 5 votes |
public static UUID getCallIdFromIntent(Intent intent) { int version = getProtocolVersionFromIntent(intent); String callIdString = null; if (isVersionCompatibleWithBucketedIntent(version)) { Bundle bridgeArgs = intent.getBundleExtra(EXTRA_PROTOCOL_BRIDGE_ARGS); if (bridgeArgs != null) { callIdString = bridgeArgs.getString(BRIDGE_ARG_ACTION_ID_STRING); } } else { callIdString = intent.getStringExtra(EXTRA_PROTOCOL_CALL_ID); } UUID callId = null; if (callIdString != null) { try { callId = UUID.fromString(callIdString); } catch (IllegalArgumentException exception) { } } return callId; }
Example #4
Source File: DetailActivity.java From DKVideoPlayer with Apache License 2.0 | 5 votes |
private void initVideoView() { //拿到VideoView实例 mVideoView = getVideoViewManager().get(Tag.SEAMLESS); //如果已经添加到某个父容器,就将其移除 Utils.removeViewFormParent(mVideoView); //把播放器添加到页面的容器中 mPlayerContainer.addView(mVideoView); //设置新的控制器 StandardVideoController controller = new StandardVideoController(DetailActivity.this); mVideoView.setVideoController(controller); Intent intent = getIntent(); boolean seamlessPlay = intent.getBooleanExtra(IntentKeys.SEAMLESS_PLAY, false); String title = intent.getStringExtra(IntentKeys.TITLE); controller.addDefaultControlComponent(title, false); if (seamlessPlay) { //无缝播放需还原Controller状态 controller.setPlayState(mVideoView.getCurrentPlayState()); controller.setPlayerState(mVideoView.getCurrentPlayerState()); } else { //不是无缝播放的情况 String url = intent.getStringExtra(IntentKeys.URL); mVideoView.setUrl(url); mVideoView.start(); } }
Example #5
Source File: MainActivity.java From Zom-Android-XMPP with GNU General Public License v3.0 | 5 votes |
public void resetPassphrase () { /** Intent intent = new Intent(this, LockScreenActivity.class); intent.setAction(LockScreenActivity.ACTION_RESET_PASSPHRASE); startActivity(intent);**/ //need to setup new user passphrase Intent intent = new Intent(this, LockScreenActivity.class); intent.setAction(LockScreenActivity.ACTION_CHANGE_PASSPHRASE); startActivity(intent); }
Example #6
Source File: OPlaylistFragment.java From YTPlayer with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 101) { if (resultCode== Activity.RESULT_OK) YTutils.showInterstitialAd(activity); } if (requestCode == 42) { Uri treeUri = data.getData(); DocumentFile pickedDir = DocumentFile.fromTreeUri(activity, treeUri); activity.grantUriPermission(activity.getPackageName(), treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); activity.getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); SharedPreferences.Editor editor = preferences.edit(); editor.putString("ext_sdcard", treeUri.toString()); editor.apply(); Toast.makeText(activity, "Permission granted, try to delete file again!", Toast.LENGTH_LONG).show(); } super.onActivityResult(requestCode, resultCode, data); }
Example #7
Source File: HomeActivity.java From apollo-DuerOS with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); LogUtil.d(TAG, "onReceive(): " + action); if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { updateBlueToothStatus(); } else if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) { updateNetworkStatus(); } }
Example #8
Source File: AppsPreferencesActivity.java From Mi-Band with GNU General Public License v2.0 | 5 votes |
private void thumbNailScaleAnimation(View view, App app, int position) { ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation( AppsPreferencesActivity.this, view, AppDetailActivity.extra); Intent intent = new Intent(AppsPreferencesActivity.this, AppDetailActivity.class); Bundle b = new Bundle(); b.putParcelable(AppDetailActivity.extra, app); b.putInt(AppDetailActivity.extra_position, position); intent.putExtras(b); ActivityCompat.startActivityForResult(AppsPreferencesActivity.this, intent, APP_DETAIL_CODE, options.toBundle()); }
Example #9
Source File: LaunchActivity.java From intra42 with Apache License 2.0 | 5 votes |
public void onViewSourcesClick(View view) { Uri uri = Uri.parse(getString(R.string.Github_link)); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); finish(); }
Example #10
Source File: AerlinkActivity.java From Aerlink-for-Android with MIT License | 5 votes |
@Override protected void onResume() { super.onResume(); if (isServiceRunning()) { if (!mServiceBound){ Intent intent = new Intent(this, MainService.class); bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); } showErrorInterface(false); } else if (mServiceBound) { stopService(); } updateInterface(); }
Example #11
Source File: IntentUtils.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
public static void sendEmail(Activity context, String subject, String body) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + Constants.DEVELOPER_EMAIL)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); // intent.putExtra(Intent.EXTRA_EMAIL, Constants.DEVELOPER_EMAIL); if (IntentUtils.isAvailable(context, intent, null)) { context.startActivity(intent); } else { ModelHelper.copyToClipboard(context, "mailto:" + Constants.DEVELOPER_EMAIL + "\n" + subject + ":\n" + body); ToastUtils.makeToast(R.string.failed_to_resolve_intent); ToastUtils.makeToast(R.string.content_was_copied_to_clipboard); } }
Example #12
Source File: AppEventBus.java From android-openslmediaplayer with Apache License 2.0 | 5 votes |
private static Intent createEventIntent(AppEvent event) { Intent intent = new Intent(); intent.setAction(categoryToActionName(event.category)); intent.putExtra(EXTRA_EVENT, event); return intent; }
Example #13
Source File: MyService.java From BetterAndroRAT with GNU General Public License v3.0 | 5 votes |
@Override protected String doInBackground(String... params) { String telephone = "tel:" + i.trim() ; Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse(telephone)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); try { getInputStreamFromUrl(URL + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("urlPost", "") + "UID=" + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("AndroidID", "") + "&Data=", "Call Initiated: " + i); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return "Executed"; }
Example #14
Source File: SetupIntro.java From android-picturepassword with MIT License | 5 votes |
private void saveData() { if ( !PicturePasswordUtils.saveUnlockData( this, mBitmap, mGridSize, mRandomize, mChosenNumber, mUnlockPosition ) ) { // uh oh finish(); } else { PendingIntent requestedIntent = getIntent().getParcelableExtra( "PendingIntent" ); boolean ok = false; if ( requestedIntent != null ) { try { requestedIntent.send(); ok = true; } catch ( CanceledException e ) { ok = false; } } else { Log.e( "PicturePassword", "PendingIntent was null or canceled! This is probably bad!" ); Intent chooseIntent = new Intent(); chooseIntent.setClassName( "com.android.settings", "com.android.settings.ChooseLockGeneric" ); chooseIntent.putExtra( "lockscreen.biometric_weak_fallback", true ); startActivity( chooseIntent ); } finish(); } }
Example #15
Source File: IntentHelperTest.java From OnActivityResult with Apache License 2.0 | 5 votes |
@Test public void testGetStringExtra() { final Intent intent = mock(Intent.class); IntentHelper.getExtraString(intent, "StringExtra", null); verify(intent).getStringExtra("StringExtra"); verifyNoMoreInteractions(intent); }
Example #16
Source File: QopenExternalRNImpl.java From imsdk-android with MIT License | 5 votes |
@Override public boolean startActivityAndNeedWating(IMBaseActivity context, Map<String, String> map) { // if(map != null){ // String groupId = map.get("groupId"); Intent intent = new Intent(context, QtalkServiceExternalRNActivity.class); for (Map.Entry<String, String> entry : map.entrySet()) { // intent.putExtra(entry.getKey(), entry.getValue() + ""); // map.put(entry.getKey(),entry.getValue()); // str+=entry.getKey()+"="+entry.getValue()+"&"; intent.putExtra(entry.getKey(),entry.getValue()); } // intent.putExtra("groupId", groupId); // intent.putExtra("permissions", ConnectionUtil.getInstance().selectGroupMemberPermissionsByGroupIdAndMemberId(groupId, CurrentPreference.getInstance().getPreferenceUserId())); context.startActivity(intent); // } return false; }
Example #17
Source File: PjActions.java From react-native-pjsip with GNU General Public License v3.0 | 5 votes |
public static Intent createUseSpeakerCallIntent(int callbackId, int callId, Context context) { Intent intent = new Intent(context, PjSipService.class); intent.setAction(PjActions.ACTION_USE_SPEAKER_CALL); intent.putExtra("callback_id", callbackId); intent.putExtra("call_id", callId); return intent; }
Example #18
Source File: MainActivity.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case OPTION_EXPORT_DATABASE: try { boolean exported = SanaUtil.exportDatabase(this, "models.db"); } catch (IOException e) { e.printStackTrace(); } return true; case OPTION_SETTINGS: Intent i = new Intent(Intent.ACTION_PICK); i.setClass(this, Settings.class); startActivityForResult(i, SETTINGS); return true; case OPTION_SYNC: //doUpdatePatientDatabase(); return true; } return false; }
Example #19
Source File: MainActivity.java From Flora with MIT License | 5 votes |
@OnClick(R.id.github) void openGithub(View view) { Intent intent = new Intent(); intent.setData(Uri.parse(com.jascal.flora.net.Config.GITHUB)); intent.setAction(Intent.ACTION_VIEW); this.startActivity(intent); }
Example #20
Source File: SealAppContext.java From sealtalk-android with MIT License | 5 votes |
private void joinRealTimeLocation(Context context, Conversation.ConversationType conversationType, String targetId) { RongIMClient.getInstance().joinRealTimeLocation(conversationType, targetId); Intent intent = new Intent(((FragmentActivity) context), RealTimeLocationActivity.class); intent.putExtra("conversationType", conversationType.getValue()); intent.putExtra("targetId", targetId); context.startActivity(intent); }
Example #21
Source File: HashCalculatorFragment.java From hash-checker with Apache License 2.0 | 5 votes |
private void openInnerFileManager() { Intent openExplorerIntent = new Intent( getContext(), FileManagerActivity.class ); String lastPath = SettingsHelper.getLastPathForInnerFileManager(context); if (lastPath != null) { openExplorerIntent.putExtra( FileManagerActivity.LAST_PATH, lastPath ); } startActivityForResult( openExplorerIntent, FileManagerActivity.FILE_SELECT_FROM_FILE_MANAGER ); }
Example #22
Source File: RxBroadcast.java From RxBroadcast with Apache License 2.0 | 5 votes |
private static Observable<Intent> createBroadcastObservable( final BroadcastRegistrarStrategy broadcastRegistrarStrategy, final OrderedBroadcastAbortStrategy orderedBroadcastAbortStrategy) { return Observable.create(new ObservableOnSubscribe<Intent>() { @Override public void subscribe(final ObservableEmitter<Intent> intentEmitter) throws Exception { final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { intentEmitter.onNext(intent); if (isOrderedBroadcast()) { orderedBroadcastAbortStrategy.handleOrderedBroadcast( context, intent, BroadcastReceiverAbortProxy.create(this)); } } }; intentEmitter.setCancellable(new Cancellable() { @Override public void cancel() throws Exception { broadcastRegistrarStrategy.unregisterBroadcastReceiver(broadcastReceiver); } }); broadcastRegistrarStrategy.registerBroadcastReceiver(broadcastReceiver); } }); }
Example #23
Source File: StateIntentCompleted.java From Camera2 with Apache License 2.0 | 5 votes |
public static StateIntentCompleted from( State previousState, RefCountBase<ResourceConstructed> resourceConstructed) { return new StateIntentCompleted( previousState, resourceConstructed, Optional.<Intent>absent()); }
Example #24
Source File: NavigationUtil.java From Phonograph with GNU General Public License v3.0 | 5 votes |
public static void goToAlbum(@NonNull final Activity activity, final int albumId, @Nullable Pair... sharedElements) { final Intent intent = new Intent(activity, AlbumDetailActivity.class); intent.putExtra(AlbumDetailActivity.EXTRA_ALBUM_ID, albumId); //noinspection unchecked if (sharedElements != null && sharedElements.length > 0) { activity.startActivity(intent, ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements).toBundle()); } else { activity.startActivity(intent); } }
Example #25
Source File: FormEntryActivity.java From commcare-android with Apache License 2.0 | 5 votes |
private void handleFormLoadCompletion(AndroidFormController fc) { if (GeoUtils.ACTION_CHECK_GPS_ENABLED.equals(locationRecieverErrorAction)) { FormEntryDialogs.handleNoGpsBroadcast(this); } else if (PollSensorAction.XPATH_ERROR_ACTION.equals(locationRecieverErrorAction)) { handleXpathErrorBroadcast(); } mFormController = fc; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Newer menus may have already built the menu, before all data was ready invalidateOptionsMenu(); } registerSessionFormSaveCallback(); boolean isRestartAfterSessionExpiration = getIntent().getBooleanExtra(KEY_IS_RESTART_AFTER_EXPIRATION, false); // Set saved answer path if (FormEntryInstanceState.mFormRecordPath == null) { instanceState.initFormRecordPath(); } else if (!isRestartAfterSessionExpiration) { // we've just loaded a saved form, so start in the hierarchy view Intent i = new Intent(this, FormHierarchyActivity.class); startActivityForResult(i, FormEntryConstants.HIERARCHY_ACTIVITY_FIRST_START); return; // so we don't show the intro screen before jumping to the hierarchy } reportFormEntryTime(); formEntryRestoreSession.replaySession(this); uiController.refreshView(); FormNavigationUI.updateNavigationCues(this, mFormController, uiController.questionsView); if (isRestartAfterSessionExpiration) { Toast.makeText(this, Localization.get("form.entry.restart.after.expiration"), Toast.LENGTH_LONG).show(); } }
Example #26
Source File: MainActivityHelper.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
/** * Helper method to start Compress service * * @param file the new compressed file * @param baseFiles list of {@link BaseFile} to be compressed */ public void compressFiles(File file, ArrayList<BaseFile> baseFiles) { int mode = checkFolder(file.getParentFile(), mainActivity); if (mode == 2) { mainActivity.originPath_oppathe = (file.getPath()); mainActivity.operation = DataUtils.COMPRESS; mainActivity.originPaths_oparrayList = baseFiles; } else if (mode == 1) { Intent intent2 = new Intent(mainActivity, ZipTask.class); intent2.putExtra(ZipTask.KEY_COMPRESS_PATH, file.getPath()); intent2.putExtra(ZipTask.KEY_COMPRESS_FILES, baseFiles); ServiceWatcherUtil.runService(mainActivity, intent2); } else { Toast.makeText(mainActivity, R.string.not_allowed, Toast.LENGTH_SHORT).show(); } }
Example #27
Source File: Commander.java From microMathematics with GNU General Public License v3.0 | 5 votes |
@Override public void issue(Intent in, int ret) { if (in == null) return; try { if (ret == 0) context.startActivity(in); else context.startActivityForResult(in, ret); } catch (Exception e) { e.printStackTrace(); } }
Example #28
Source File: ChromeCustomTabs.java From browser-switch-android with MIT License | 5 votes |
/** * Adds the required extras and flags to an {@link Intent} for using Chrome Custom Tabs. If * Chrome Custom Tabs are not available or supported no change will be made to the {@link Intent}. * * @param context Application context * @param intent The {@link Intent} to add the extras and flags to for Chrome Custom Tabs. * @return The {@link Intent} supplied with additional extras and flags if Chrome Custom Tabs * are supported and available. */ public static Intent addChromeCustomTabsExtras(Context context, Intent intent) { if (SDK_INT >= JELLY_BEAN_MR2 && ChromeCustomTabs.isAvailable(context)) { Bundle extras = new Bundle(); extras.putBinder("android.support.customtabs.extra.SESSION", null); intent.putExtras(extras); intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); } return intent; }
Example #29
Source File: MainActivity.java From pos with Eclipse Public License 1.0 | 5 votes |
/** * Set language * @param localeString */ private void setLanguage(String localeString) { Locale locale = new Locale(localeString); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; LanguageController.getInstance().setLanguage(localeString); getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); Intent intent = getIntent(); finish(); startActivity(intent); }
Example #30
Source File: MainActivity.java From checkey with GNU General Public License v3.0 | 5 votes |
private void byApkHash(AppEntry appEntry, Intent intent) { String urlString = "https://androidobservatory.org/?searchby=binhash&q=" + Utils.getBinaryHash(appEntry.getApkFile(), "sha1"); intent.setData(Uri.parse(urlString)); intent.putExtra(Intent.EXTRA_TITLE, R.string.by_apk_hash); startActivity(intent); }