List of usage examples for android.content Intent getAction
public @Nullable String getAction()
From source file:com.parse.ParsePushBroadcastReceiver.java
/** * Delegates the generic {@code onReceive} event to a notification lifecycle event. * Subclasses are advised to override the lifecycle events and not this method. * * @param context//w w w. j a v a 2 s.c o m * The {@code Context} in which the receiver is running. * @param intent * An {@code Intent} containing the channel and data of the current push notification. * * @see ParsePushBroadcastReceiver#onPushReceive(Context, Intent) * @see ParsePushBroadcastReceiver#onPushOpen(Context, Intent) * @see ParsePushBroadcastReceiver#onPushDismiss(Context, Intent) */ @Override public void onReceive(Context context, Intent intent) { String intentAction = intent.getAction(); switch (intentAction) { case ACTION_PUSH_RECEIVE: onPushReceive(context, intent); break; case ACTION_PUSH_DELETE: onPushDismiss(context, intent); break; case ACTION_PUSH_OPEN: onPushOpen(context, intent); break; } }
From source file:com.ddj.launcher2.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;//from ww w . j ava2 s . co m } Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (intent == null) { return; } // This name is only used for comparisons and notifications, so fall back to activity name // if not supplied String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (name == null) { try { PackageManager pm = context.getPackageManager(); ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0); name = info.loadLabel(pm).toString(); } catch (PackageManager.NameNotFoundException nnfe) { return; } } Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); // Queue the item up for adding if launcher has not loaded properly yet boolean launcherNotLoaded = LauncherModel.getCellCountX() <= 0 || LauncherModel.getCellCountY() <= 0; PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; if (mUseInstallQueue || launcherNotLoaded) { String spKey = LauncherUtil.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); } else { processInstallShortcut(context, info); } }
From source file:com.offbye.bookmaster.android.book.SearchBookContentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || (!intent.getAction().equals(Intents.SearchBookContents.ACTION))) { finish();/*from ww w .j a v a 2 s. c o m*/ return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (isbn.startsWith("http://google.com/books?id=")) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && initialQuery.length() > 0) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = (Button) findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
From source file:com.android.launcher4.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;//from w w w . j av a 2 s. c om } if (DBG) Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0)); Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (intent == null) { return; } // This name is only used for comparisons and notifications, so fall back to activity name // if not supplied String name = ensureValidName(context, intent, data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME)).toString(); Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); // Queue the item up for adding if launcher has not loaded properly yet LauncherAppState.setApplicationContext(context.getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); boolean launcherNotLoaded = (app.getDynamicGrid() == null); PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; String spKey = LauncherAppState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); if (!mUseInstallQueue && !launcherNotLoaded) { flushInstallQueue(context); } }
From source file:com.hayageek.QRAuth.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.v("####", "Request:" + requestCode + "resultCOde:" + resultCode + " Data:" + data); if (data != null && data.getAction() != null && data.getAction().equals(ACTION_SCAN)) //QR Code {/*from ww w. j a v a 2 s . c om*/ IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); if (scanningResult != null) { String qrStr = scanningResult.getContents(); String scanFormat = scanningResult.getFormatName(); AccessToken accessToken = AccessToken.getCurrentAccessToken(); if (accessToken == null) { showText("User not Logged In"); } else { sendToServer(accessToken.getToken(), qrStr); } super.onActivityResult(requestCode, resultCode, data); //we have a result } else { showText("No QR scan data received"); } } else if (data != null) { callbackManager.onActivityResult(requestCode, resultCode, data); } }
From source file:com.google.android.gcm.GCMBaseIntentService.java
@Override public final void onHandleIntent(Intent intent) { try {/*from w ww. j av a 2 s. c o m*/ Context context = getApplicationContext(); String action = intent.getAction(); if (action.equals(INTENT_FROM_GCM_REGISTRATION_CALLBACK)) { handleRegistration(context, intent); } else if (action.equals(INTENT_FROM_GCM_MESSAGE)) { // checks for special messages String messageType = intent.getStringExtra(EXTRA_SPECIAL_MESSAGE); if (messageType != null) { if (messageType.equals(VALUE_DELETED_MESSAGES)) { String sTotal = intent.getStringExtra(EXTRA_TOTAL_DELETED); if (sTotal != null) { try { int total = Integer.parseInt(sTotal); Log.v(TAG, "Received deleted messages " + "notification: " + total); onDeletedMessages(context, total); } catch (NumberFormatException e) { Log.e(TAG, "GCM returned invalid number of " + "deleted messages: " + sTotal); } } } else { // application is not using the latest GCM library Log.e(TAG, "Received unknown special message: " + messageType); } } else { onMessage(context, intent); } } else if (action.equals(INTENT_FROM_GCM_LIBRARY_RETRY)) { String token = intent.getStringExtra(EXTRA_TOKEN); if (!TOKEN.equals(token)) { // make sure intent was generated by this class, not by a // malicious app. Log.e(TAG, "Received invalid token: " + token); return; } // retry last call if (GCMRegistrar.isRegistered(context)) { GCMRegistrar.internalUnregister(context); } else { GCMRegistrar.internalRegister(context, mSenderId); } } } finally { // Release the power lock, so phone can get back to sleep. // The lock is reference-counted by default, so multiple // messages are ok. // If onMessage() needs to spawn a thread or do something else, // it should use its own lock. /* synchronized (LOCK) { // sanity check for null as this is a public method if (sWakeLock != null) { Log.v(TAG, "Releasing wakelock"); sWakeLock.release(); } else { // should never happen during normal workflow Log.e(TAG, "Wakelock reference is null"); } }*/ } }
From source file:ca.zadrox.dota2esportticker.service.UpdateMatchService.java
@Override protected void onHandleIntent(Intent intent) { final String action = intent.getAction(); if (ACTION_UPDATE_MATCHES.equals(action)) { updateMatches(true);/*from w w w . j a v a2s .c o m*/ } if (ACTION_AUTO_UPDATE_MATCHES.equals(action)) { autoUpdateMatches(); } if (ACTION_SCHEDULE_AUTO_UPDATE.equals(action)) { scheduleAutoUpdates(); } if (ACTION_CANCEL_AUTO_UPDATE.equals(action)) { cancelAutoUpdate(); } if (ACTION_UPDATE_RESULTS.equals(action)) { updateResults(); } }
From source file:org.openbmap.activities.DialogPreferenceCatalogs.java
/** * Initialises download manager for GINGERBREAD and newer *///w ww .java2s . c o m @SuppressLint("NewApi") private void initDownloadManager() { mDownloadManager = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE); mReceiver = new BroadcastReceiver() { @SuppressLint("NewApi") @Override public void onReceive(final Context context, final Intent intent) { final String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { final long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); final DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(downloadId); final Cursor c = mDownloadManager.query(query); if (c.moveToFirst()) { final int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) { // we're not checking download id here, that is done in handleDownloads final String uriString = c .getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); handleDownloads(uriString); } else { final int reason = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON)); Log.e(TAG, "Download failed: " + reason); } } } } }; getContext().registerReceiver(mReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); }
From source file:android.support.v7.widget.ShareActionProvider.java
/** * Sets an intent with information about the share action. Here is a * sample for constructing a share intent: * <p>/*from w w w .j a v a2 s . co m*/ * <pre> * <code> * Intent shareIntent = new Intent(Intent.ACTION_SEND); * shareIntent.setType("image/*"); * Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg")); * shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString()); * </pre> * </code> * </p> * * @param shareIntent The share intent. * * @see Intent#ACTION_SEND * @see Intent#ACTION_SEND_MULTIPLE */ public void setShareIntent(Intent shareIntent) { if (shareIntent != null) { final String action = shareIntent.getAction(); if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { updateIntent(shareIntent); } } ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); dataModel.setIntent(shareIntent); }
From source file:com.hybris.mobile.app.commerce.fragment.OrderDetailFragment.java
@Override public void onResume() { super.onResume(); mComingFromSearch = getActivity().getIntent().getExtras() != null && getActivity().getIntent().getExtras().getBoolean(IntentConstants.ORDER_FROM_SEARCH); QueryOrder queryOrder = new QueryOrder(); Intent intent = getActivity().getIntent(); if (intent.hasExtra(IntentConstants.ORDER_CODE)) { queryOrder.setCode(getActivity().getIntent().getStringExtra(IntentConstants.ORDER_CODE)); } else if (StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) { queryOrder.setCode(RegexUtils.getOrderCode(intent.getDataString())); }/*from www . j a va 2 s .co m*/ // Getting the order CommerceApplication.getContentServiceHelper().getOrder(this, mOrderRequestId, queryOrder, null, false, null, new OnRequestListener() { @Override public void beforeRequest() { //hide when loading UIUtils.showLoadingActionBar(getActivity(), true); getView().setVisibility(View.INVISIBLE); } @Override public void afterRequestBeforeResponse() { } @Override public void afterRequest(boolean isDataSynced) { getView().setVisibility(View.VISIBLE); UIUtils.showLoadingActionBar(getActivity(), false); } }); }