List of usage examples for android.content Intent getAction
public @Nullable String getAction()
From source file:com.parse.GCMService.java
private void onHandleIntent(Intent intent) { if (intent != null) { String action = intent.getAction(); if (REGISTER_RESPONSE_ACTION.equals(action)) { handleGcmRegistrationIntent(intent); } else if (RECEIVE_PUSH_ACTION.equals(action)) { handleGcmPushIntent(intent); } else {/* w ww .ja va 2 s. c om*/ PLog.e(TAG, "PushService got unknown intent in GCM mode: " + intent); } } }
From source file:com.fastbootmobile.rssdemo.PushReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "ACTION : " + intent.getAction()); // Debug log the intent "action" // Get the shared preferences for OwnPush keys SharedPreferences pref = context.getApplicationContext().getSharedPreferences(OwnPushClient.PREF_PUSH, Context.MODE_PRIVATE); if (intent.getAction().equals(OwnPushClient.INTENT_RECEIVE)) { // This is a push message Log.d(TAG, "Decrypt : " + intent.getExtras().getString(OwnPushClient.EXTRA_DATA)); OwnPushCrypto fp = new OwnPushCrypto(); // Create a crypto object for decrypt // Get the app key pair from shared preferences (these have been confirmed by the register intent) OwnPushCrypto.AppKeyPair keys = fp.getKey(pref.getString(OwnPushClient.PREF_PUBLIC_KEY, ""), pref.getString(OwnPushClient.PREF_PRIVATE_KEY, "")); // Decrypt the message from the intent extra data String msg = fp.decryptFromIntent(intent.getExtras(), BuildConfig.APP_PUBLIC_KEY, keys); JSONObject jObj;/*from w w w . j a va2s . co m*/ if (msg != null) { Log.e(TAG, "RSS : " + msg); try { // Decode the JOSN data in the message jObj = new JSONObject(msg); Intent i = new Intent(Intent.ACTION_VIEW); // Create the intent i.setData(Uri.parse(jObj.getString("link"))); // Set the data using URI (these are web links) // Convert to pending intent PendingIntent pIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), i, 0); // Create the notification Notification n = new Notification.Builder(context.getApplicationContext()) .setContentTitle("OwnPush RSS") // Main Title .setContentText(jObj.getString("title")) // Set content .setContentIntent(pIntent) // Add the pending intent .setSmallIcon(R.drawable.ic_done).setAutoCancel(true) // Remove notification if opened .build(); n.defaults |= Notification.DEFAULT_SOUND; // Make some noise on push // Get the notification manager and display notification NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notification_num, n); // Increase the notification counter by 1 notification_num++; } catch (Exception e) { return; } } } }
From source file:com.github.opengarageapp.GarageToggleService.java
@Override protected HttpsURLConnection getRequestFromIntent(String baseString, Intent intent) throws ClientProtocolException, IOException { HttpsURLConnection urlConnection = null; URL url = null;/*from w w w . j a v a 2s . com*/ if (intent.getAction().equals(INTENT_TOGGLE1)) { url = new URL(baseString + "/doorCommand?door=1&command=Toggle"); urlConnection = (HttpsURLConnection) url.openConnection(); } else if (intent.getAction().equals(INTENT_CLOSE1)) { url = new URL(baseString + "/doorCommand?door=1&command=Toggle"); urlConnection = (HttpsURLConnection) url.openConnection(); } else { throw new IllegalArgumentException("Invalid action passed: " + intent.getAction()); } urlConnection.setRequestMethod(HttpPost.METHOD_NAME); setupConnectionProperties(urlConnection); //urlConnection.setSSLSocketFactory(GarageSSLSocketFactory.getSSLSocketFactory(application)); return urlConnection; }
From source file:com.novoda.imageloader.core.service.CacheCleanerTest.java
private Intent prepareStandardIntent() { Intent i = Mockito.mock(Intent.class); when(i.getAction()).thenReturn(CacheCleaner.CLEAN_CACHE_ACTION); when(i.hasExtra(CacheCleaner.CACHE_DIR_EXTRA)).thenReturn(true); when(i.getStringExtra(CacheCleaner.CACHE_DIR_EXTRA)).thenReturn(cacheDir.getAbsolutePath()); return i;/*ww w . j ava 2 s . com*/ }
From source file:dk.dtu.imm.datacollector.MainPipeline.java
@Override protected void onHandleIntent(Intent intent) { if (ACTION_RUN_ONCE.equals(intent.getAction())) { String probeName = intent.getStringExtra(RUN_ONCE_PROBE_NAME); runProbeOnceNow(probeName);//from w ww .j a va 2s . co m } else { super.onHandleIntent(intent); } }
From source file:com.nadmm.airports.library.LibraryService.java
@Override protected void onHandleIntent(Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_CHECK_BOOKS)) { checkBooks(intent); } else if (action.equals(ACTION_GET_BOOK)) { getBook(intent);/*from www. ja va 2s . com*/ } else if (action.equals(ACTION_DELETE_BOOK)) { deleteBook(intent); } }
From source file:com.dmbstream.android.activity.SearchResultsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { query = intent.getStringExtra(SearchManager.QUERY); } else {//w w w. j a v a2 s .c o m query = intent.getStringExtra(Constants.EXTRA_QUERY_TERM); Log.d(TAG, "Query from other intent: " + query); } // After setting up variables so that they can be accessed in getApiUrl // which is called at the end of super.onCreate super.onCreate(savedInstanceState); // Push the search box into the layout group below the logo bar and above // the 'search results' title bar ViewGroup container = (ViewGroup) findViewById(R.id.TitleGroup); container.addView(ViewGroup.inflate(this, R.layout.partial_search_box, null), 0); searchBox = (EditText) findViewById(R.id.SearchText); searchBox.setText(query); searchBox.setOnKeyListener(this); ImageButton searchButton = (ImageButton) findViewById(R.id.search_go_button); searchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AnalyticsUtil.trackEvent(SearchResultsActivity.this, "SearchResults", "Click", "Search", 0); search(); } }); inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null) { inputMethodManager.hideSoftInputFromWindow(searchBox.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:at.bitfire.nophonespam.CallReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(intent.getAction()) && intent .getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) { String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); Log.i(TAG, "Received call: " + incomingNumber); Settings settings = new Settings(context); if (TextUtils.isEmpty(incomingNumber)) { // private number (no caller ID) if (settings.blockHiddenNumbers()) rejectCall(context, null); } else {/*from w ww. j a v a 2 s. c o m*/ DbHelper dbHelper = new DbHelper(context); try { SQLiteDatabase db = dbHelper.getWritableDatabase(); Cursor c = db.query(Number._TABLE, null, "? LIKE " + Number.NUMBER, new String[] { incomingNumber }, null, null, null); if (c.moveToNext()) { ContentValues values = new ContentValues(); DatabaseUtils.cursorRowToContentValues(c, values); Number number = Number.fromValues(values); rejectCall(context, number); values.clear(); values.put(Number.LAST_CALL, System.currentTimeMillis()); values.put(Number.TIMES_CALLED, number.timesCalled + 1); db.update(Number._TABLE, values, Number.NUMBER + "=?", new String[] { number.number }); BlacklistObserver.notifyUpdated(); } c.close(); } finally { dbHelper.close(); } } } }
From source file:barqsoft.footballscores.widget.WidgetListProvider.java
@Override public void onReceive(@NonNull Context context, @NonNull Intent intent) { super.onReceive(context, intent); if (ScoresSyncAdapter.ACTION_DATA_UPDATED.equals(intent.getAction())) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, getClass())); //This method will trigger WidgetListRemoteViewsService RemoteViewsFactory // .onDataChanged() and update the widget UI appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list); }/*from www . j a v a2 s . com*/ }
From source file:cl.chihau.holaauto.MessagingService.java
@Override protected void onHandleIntent(Intent intent) { // Handle intent to send a new notification. if (intent != null && SEND_MESSAGE_ACTION.equals(intent.getAction())) { sendNotificationForConversation(Conversations.CONVERSATION_ID, Conversations.SENDER_NAME, Conversations.getUnreadMessage(), System.currentTimeMillis()); }//from ww w . j a v a2 s. c om }