List of usage examples for android.content Intent getType
public @Nullable String getType()
From source file:org.awesomeapp.messenger.MainActivity.java
private void handleIntent() { Intent intent = getIntent(); if (intent != null) { Uri data = intent.getData();//from w ww. jav a 2 s. co m String type = intent.getType(); if (data != null && Imps.Chats.CONTENT_ITEM_TYPE.equals(type)) { long chatId = ContentUris.parseId(data); Intent intentChat = new Intent(this, ConversationDetailActivity.class); intentChat.putExtra("id", chatId); startActivity(intentChat); } else if (Imps.Contacts.CONTENT_ITEM_TYPE.equals(type)) { long providerId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, mApp.getDefaultProviderId()); long accountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, mApp.getDefaultAccountId()); String username = intent.getStringExtra(ImServiceConstants.EXTRA_INTENT_FROM_ADDRESS); startChat(providerId, accountId, username, true, true); } else if (intent.hasExtra("username")) { //launch a new chat based on the intent value startChat(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), intent.getStringExtra("username"), true, true); } setIntent(null); } }
From source file:com.android.providers.downloads.DownloadThread.java
/** * Transfer the downloaded destination file to the DRM store. *//* ww w . ja v a 2 s. c o m*/ private void transferToDrm(State state) throws StopRequest { File file = new File(state.mFilename); Intent item = DrmStore.addDrmFile(mContext.getContentResolver(), file, null); file.delete(); if (item == null) { throw new StopRequest(Downloads.Impl.STATUS_UNKNOWN_ERROR, "unable to add file to DrmProvider"); } else { state.mFilename = item.getDataString(); state.mMimeType = item.getType(); } }
From source file:com.vuze.android.remote.activity.TorrentViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); AndroidUtilsUI.onCreate(this); super.onCreate(savedInstanceState); Intent intent = getIntent(); if (DEBUG) {//from w w w . j a v a 2s . co m Log.d(TAG, "TorrentViewActivity intent = " + intent); Log.d(TAG, "Type:" + intent.getType() + ";" + intent.getDataString()); } final Bundle extras = intent.getExtras(); if (extras == null) { Log.e(TAG, "No extras!"); finish(); return; } String remoteProfileID = extras.getString(SessionInfoManager.BUNDLE_KEY); if (remoteProfileID != null) { sessionInfo = SessionInfoManager.getSessionInfo(remoteProfileID, this); } if (sessionInfo == null) { Log.e(TAG, "sessionInfo NULL!"); finish(); return; } sessionInfo.addRpcAvailableListener(this); sessionInfo.addSessionSettingsChangedListeners(this); remoteProfile = sessionInfo.getRemoteProfile(); setContentView(R.layout.activity_torrent_view); setupActionBar(); // setup view ids now because listeners below may trigger as soon as we // get them tvUpSpeed = (TextView) findViewById(R.id.wvUpSpeed); tvDownSpeed = (TextView) findViewById(R.id.wvDnSpeed); tvCenter = (TextView) findViewById(R.id.wvCenter); toolbar = (Toolbar) findViewById(R.id.toolbar_bottom); setBottomToolbarEnabled(enableBottomToolbar); setSubtitle(remoteProfile.getNick()); boolean isLocalHost = remoteProfile.isLocalHost(); if (!VuzeRemoteApp.getNetworkState().isOnline() && !isLocalHost) { Resources resources = getResources(); String msg = resources.getString(R.string.no_network_connection); String reason = VuzeRemoteApp.getNetworkState().getOnlineStateReason(); if (reason != null) { msg += "\n\n" + reason; } AndroidUtils.showConnectionError(this, msg, false); return; } onCreate_setupDrawer(); }
From source file:org.torproject.android.Orbot.java
private synchronized void handleIntents() { if (getIntent() == null) return;/*ww w. jav a 2 s .c om*/ // Get intent, action and MIME type Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (action == null) return; if (action.equals("org.torproject.android.REQUEST_HS_PORT")) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: int hsPort = getIntent().getIntExtra("hs_port", -1); enableHiddenServicePort(hsPort); finish(); break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked finish(); break; } } }; int hsPort = getIntent().getIntExtra("hs_port", -1); String requestMsg = getString(R.string.hidden_service_request, hsPort); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener) .setNegativeButton("Deny", dialogClickListener).show(); } else if (action.equals("org.torproject.android.START_TOR")) { autoStartFromIntent = true; try { startTor(); Intent nResult = new Intent(); //nResult.putExtra("socks", ); //TODO respond with socks, transport, dns, etc setResult(RESULT_OK, nResult); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (action.equals(Intent.ACTION_VIEW)) { String urlString = intent.getDataString(); if (urlString != null) { if (urlString.toLowerCase().startsWith("bridge://")) { String newBridgeValue = urlString.substring(9); //remove the bridge protocol piece newBridgeValue = URLDecoder.decode(newBridgeValue); //decode the value here showAlert("Bridges Updated", "Restart Orbot to use this bridge: " + newBridgeValue, false); String bridges = mPrefs.getString(TorConstants.PREF_BRIDGES_LIST, null); Editor pEdit = mPrefs.edit(); if (bridges != null && bridges.trim().length() > 0) { if (bridges.indexOf('\n') != -1) bridges += '\n' + newBridgeValue; else bridges += ',' + newBridgeValue; } else bridges = newBridgeValue; pEdit.putString(TorConstants.PREF_BRIDGES_LIST, bridges); //set the string to a preference pEdit.putBoolean(TorConstants.PREF_BRIDGES_ENABLED, true); pEdit.commit(); setResult(RESULT_OK); } } } else { showWizard = mPrefs.getBoolean("show_wizard", showWizard); if (showWizard) { Editor pEdit = mPrefs.edit(); pEdit.putBoolean("show_wizard", false); pEdit.commit(); showWizard = false; startActivity(new Intent(this, ChooseLocaleWizardActivity.class)); } } setIntent(null); updateStatus(""); }
From source file:com.hivewallet.androidclient.wallet.ui.WalletActivity.java
private void handleIntent(@Nonnull final Intent intent) { final String action = intent.getAction(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { final String inputType = intent.getType(); final NdefMessage ndefMessage = (NdefMessage) intent .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0]; final byte[] input = Nfc.extractMimePayload(Constants.MIMETYPE_TRANSACTION, ndefMessage); new BinaryInputParser(inputType, input) { @Override//from ww w .ja va 2 s . c o m protected void handlePaymentIntent(final PaymentIntent paymentIntent) { cannotClassify(inputType); } @Override protected void error(final int messageResId, final Object... messageArgs) { dialog(WalletActivity.this, null, 0, messageResId, messageArgs); } }.parse(); } }
From source file:de.enlightened.peris.PerisMain.java
/** * Called when the activity is first created. *//*w w w . ja v a2s . co m*/ @SuppressLint("NewApi") @Override public final void onCreate(final Bundle savedInstanceState) { this.application = (PerisApp) getApplication(); this.application.setActive(true); this.backStackId = this.application.getBackStackId(); this.ah = this.application.getAnalyticsHelper(); if (this.application.getSession().getServer().serverIcon == null) { final int optimalIconSize = (int) this.getResources().getDimension(android.R.dimen.app_icon_size); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { new CheckForumIconTask(this.application.getSession(), optimalIconSize) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { new CheckForumIconTask(this.application.getSession(), optimalIconSize).execute(); } } this.serverAddress = this.application.getSession().getServer().serverAddress; final SharedPreferences appPreferences = getSharedPreferences("prefs", 0); this.sidebarOption = appPreferences.getBoolean("show_sidebar", true); this.screenTitle = getString(R.string.app_name); if (getString(R.string.server_location).contentEquals("0")) { this.storagePrefix = this.serverAddress + "_"; this.screenSubtitle = this.serverAddress; } else { this.screenSubtitle = this.screenTitle; } this.serverUserid = this.application.getSession().getServer().serverUserId; final String tagline = this.application.getSession().getServer().serverTagline; final SharedPreferences.Editor editor = appPreferences.edit(); if (tagline.contentEquals("null") || tagline.contentEquals("0")) { final String deviceName = android.os.Build.MODEL; final String appName = getString(R.string.app_name); final String appVersion = getString(R.string.app_version); String appColor = getString(R.string.default_color); if (this.application.getSession().getServer().serverColor.contains("#")) { appColor = this.application.getSession().getServer().serverColor; } final String standardTagline = "[color=" + appColor + "][b]Sent from my " + deviceName + " using " + appName + " v" + appVersion + ".[/b][/color]"; this.application.getSession().getServer().serverTagline = standardTagline; this.application.getSession().updateServer(); } editor.putInt(this.storagePrefix + "just_logged_in", 0); editor.commit(); if (this.serverUserid != null) { final Toast toast = Toast.makeText(PerisMain.this, "TIP: Tap on the key icon to log in to your forum account.", Toast.LENGTH_LONG); toast.show(); } final Intent intent = getIntent(); final String action = intent.getAction(); final String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { this.handleSendText(intent); // Handle text being sent } else if (type.startsWith("image/")) { this.handleSendImage(intent); // Handle single image being sent } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { if (type.startsWith("image/")) { this.handleSendMultipleImages(intent); // Handle multiple images being sent } } /*else { // Handle other intents, such as being started from the home screen }*/ this.background = this.application.getSession().getServer().serverColor; ThemeSetter.setTheme(this, this.background); super.onCreate(savedInstanceState); ThemeSetter.setActionBar(this, this.background); this.actionBar = getActionBar(); this.actionBar.setDisplayHomeAsUpEnabled(true); this.actionBar.setHomeButtonEnabled(true); this.actionBar.setTitle(this.screenTitle); this.actionBar.setSubtitle(this.screenSubtitle); //Send app analytics data this.ah.trackScreen(getClass().getSimpleName(), false); this.ah.trackEvent("server connection", "connected", "connected", false); //Send tracking data for parsed analytics from peris.json this.serverAddress = this.application.getSession().getServer().analyticsId; if (this.serverAddress != null) { this.ah.trackCustomScreen(this.serverAddress, "Peris Forum Reader v" + getString(R.string.app_version) + " for Android"); } setContentView(R.layout.main_swipe); this.mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); this.flSecondary = (FrameLayout) findViewById(R.id.main_page_frame_right); this.seperator = findViewById(R.id.main_page_seperator); //Setup forum background final String forumWallpaper = this.application.getSession().getServer().serverWallpaper; final String forumBackground = this.application.getSession().getServer().serverBackground; if (forumBackground != null && forumBackground.contains("#") && forumBackground.length() == 7) { this.mDrawerLayout.setBackgroundColor(Color.parseColor(forumBackground)); } else { this.mDrawerLayout.setBackgroundColor(Color.parseColor(getString(R.string.default_background))); } if (forumWallpaper != null && forumWallpaper.contains("http")) { final ImageView mainSwipeImageBackground = (ImageView) findViewById(R.id.main_swipe_image_background); final String imageUrl = forumWallpaper; ImageLoader.getInstance().displayImage(imageUrl, mainSwipeImageBackground); } else { findViewById(R.id.main_swipe_image_background).setVisibility(View.GONE); } this.setupSlidingDrawer(); if (this.application.getStackManager().getBackStackSize(this.backStackId) == 0) { final Bundle bundle = this.initializeNewSession(appPreferences); this.loadCategory(bundle, "NEW_SESSION", false); //application.stackManager.addToBackstack(backStackId, BackStackManager.BackStackItem.BACKSTACK_TYPE_FORUM,bundle); } else { this.recoverBackstack(); } final Bundle parms = getIntent().getExtras(); if (parms != null) { if (parms.containsKey("stealing")) { final Boolean stealing = parms.getBoolean("stealing"); if (stealing) { final String stealingLocation = parms.getString("stealing_location", "0"); final String stealingType = parms.getString("stealing_type", "0"); final boolean locationNumeric = isNumeric(stealingLocation); if (stealingType.contentEquals("forum") && locationNumeric && !stealingLocation.contentEquals("0")) { this.loadTopicItem(Category.builder().id(stealingLocation).name("External Link").build()); } if (stealingType.contentEquals("topic") && locationNumeric && !stealingLocation.contentEquals("0")) { this.loadTopicItem(Topic.builder().id(stealingLocation).title("External Link").build()); } } } } //Juice up gesture listener this.enableGestures(); }
From source file:com.bt.download.android.gui.activities.AudioPlayerActivity.java
/** * Checks whether the passed intent contains a playback request, * and starts playback if that's the case *//*w w w . j av a 2 s. c om*/ private void startPlayback() { Intent intent = getIntent(); if (intent == null || mService == null) { return; } Uri uri = intent.getData(); String mimeType = intent.getType(); boolean handled = false; if (uri != null && uri.toString().length() > 0) { MusicUtils.playFile(this, uri); handled = true; } else if (Playlists.CONTENT_TYPE.equals(mimeType)) { long id = parseIdFromIntent(intent, "playlistId", "playlist", -1); if (id >= 0) { MusicUtils.playPlaylist(this, id); handled = true; } } else if (Albums.CONTENT_TYPE.equals(mimeType)) { long id = parseIdFromIntent(intent, "albumId", "album", -1); if (id >= 0) { int position = intent.getIntExtra("position", 0); MusicUtils.playAlbum(this, id, position); handled = true; } } else if (Artists.CONTENT_TYPE.equals(mimeType)) { long id = parseIdFromIntent(intent, "artistId", "artist", -1); if (id >= 0) { int position = intent.getIntExtra("position", 0); MusicUtils.playArtist(this, id, position); handled = true; } } if (handled) { // Make sure to process intent only once setIntent(new Intent()); // Refresh the queue ((QueueFragment) mPagerAdapter.getFragment(0)).refreshQueue(); } }
From source file:com.nononsenseapps.notepad.MainActivity.java
private void handleInsertIntent(Intent intent) { if (intent.getType() != null && intent.getType().equals(NotePad.Lists.CONTENT_TYPE) || intent.getData() != null && intent.getData().equals(NotePad.Lists.CONTENT_VISIBLE_URI)) { // get Title if (intent.getExtras() != null) { String title = intent.getExtras().getString(NotePad.Lists.COLUMN_NAME_TITLE, ""); createList(title);//w w w.j a v a 2 s.c om } } else if (intent.getType() != null && (intent.getType().equals(NotePad.Notes.CONTENT_TYPE) || intent.getType().startsWith("text/")) || intent.getData() != null && intent.getData().equals(NotePad.Notes.CONTENT_VISIBLE_URI)) { Log.d("FragmentLayout", "INSERT NOTE"); // Get list to create note in first long listId = getAList(intent); String text = ""; if (intent.getExtras() != null) { text = intent.getExtras().getCharSequence(Intent.EXTRA_TEXT, "").toString(); } if (listId > -1) { Uri noteUri = MainActivity.createNote(this, listId, text); if (noteUri != null) { Bundle arguments = new Bundle(); arguments.putLong(NotesEditorFragment.KEYID, NotesEditorFragment.getIdFromUri(noteUri)); NotesEditorFragment fragment = new NotesEditorFragment(); fragment.setArguments(arguments); getFragmentManager().beginTransaction().replace(R.id.rightFragment, fragment).commit(); } // Open appropriate list if tablet mode if (this.currentContent == CONTENTVIEW.DUAL) { // Open the containing list if we have to. No need to // change // lists // if we are already displaying all notes. openListFromIntent(listId, intent); } } } }
From source file:org.qeo.android.service.QeoService.java
@Override public IBinder onBind(Intent intent) { // binder should return the correct version of the requested aidl interface. Make sure to update // QeoServiceVersion too if new version is created. mOtpDialogCanceled = false;/* ww w . j a va2s.c o m*/ String action = intent.getAction(); if (action != null) { LOG.info("Binding to Qeo Service (action: " + action + ", type: " + intent.getType() + ")"); } if (AidlConstants.AIDL_SERVICE_ACTION_V1.equals(action)) { return mBinderV1; } else { // default return mBinderV1; } }
From source file:com.github.dfa.diaspora_android.activity.MainActivity.java
/** * Handle intents and execute intent specific actions * * @param intent intent to get handled/*from ww w. j a v a 2 s .c o m*/ */ private void handleIntent(Intent intent) { AppLog.i(this, "handleIntent()"); if (intent == null) { AppLog.v(this, "Intent was null"); return; } String action = intent.getAction(); String type = intent.getType(); String loadUrl = null; AppLog.v(this, "Action: " + action + " Type: " + type); if (Intent.ACTION_MAIN.equals(action)) { loadUrl = urls.getStreamUrl(); } else if (ACTION_OPEN_URL.equals(action)) { loadUrl = intent.getStringExtra(URL_MESSAGE); } else if (Intent.ACTION_VIEW.equals(action) && intent.getDataString() != null) { Uri data = intent.getData(); if (data != null && data.toString().startsWith(CONTENT_HASHTAG)) { handleHashtag(intent); return; } else { loadUrl = intent.getDataString(); AppLog.v(this, "Intent has a delicious URL for us: " + loadUrl); } } else if (ACTION_CHANGE_ACCOUNT.equals(action)) { AppLog.v(this, "Reset pod data and show PodSelectionFragment"); appSettings.setPod(null); runOnUiThread(new Runnable() { public void run() { navheaderTitle.setText(R.string.app_name); navheaderDescription.setText(R.string.app_subtitle); navheaderImage.setImageResource(R.drawable.ic_launcher); app.resetPodData( ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView()); } }); showFragment(getFragment(PodSelectionFragment.TAG)); } else if (ACTION_CLEAR_CACHE.equals(action)) { AppLog.v(this, "Clear WebView cache"); runOnUiThread(new Runnable() { public void run() { ContextMenuWebView wv = ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)) .getWebView(); if (wv != null) { wv.clearCache(true); } } }); } else if (Intent.ACTION_SEND.equals(action) && type != null) { switch (type) { case "text/plain": if (intent.hasExtra(Intent.EXTRA_SUBJECT)) { handleSendSubject(intent); } else { handleSendText(intent); } break; case "image/*": handleSendImage(intent); //TODO: Add intent filter to Manifest and implement method break; } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { /* TODO: Implement and add filter to manifest */ return; } //Catch split screen recreation if (action != null && action.equals(Intent.ACTION_MAIN) && getTopFragment() != null) { return; } if (loadUrl != null) { navDrawer.closeDrawers(); openDiasporaUrl(loadUrl); } }