List of usage examples for android.content Intent setAction
public @NonNull Intent setAction(@Nullable String action)
From source file:com.java2s.intents4.IntentsDemo4Activity.java
private Intent createIntentFromEditTextFields() { String theAction = actionText.getText().toString().trim(); String theUri = uriText.getText().toString().trim(); String theMimeType = mimeTypeText.getText().toString().trim(); Intent intent = new Intent(); if (theAction.length() != 0) { intent.setAction(theAction); }//from w w w .j ava2s. c o m intentHasBothUriAndType = false; if (theUri.length() != 0 && theMimeType.length() != 0) { intentHasBothUriAndType = true; intent.setDataAndType(Uri.parse(theUri), theMimeType); } else if (theUri.length() != 0) { intent.setData(Uri.parse(theUri)); } else if (theMimeType.length() != 0) { intent.setType(theMimeType); } if (intentCategoriesLayout != null) { int count = intentCategoriesLayout.getChildCount(); for (int i = 0; i < count; i++) { String cat = ((EditText) ((ViewGroup) intentCategoriesLayout.getChildAt(i)).getChildAt(1)).getText() .toString().trim(); if (cat.length() != 0) { intent.addCategory(cat); } } } Log.i(CLASSNAME, intent.toString()); return intent; }
From source file:com.daskiworks.ghwatch.backend.UnreadNotificationsService.java
protected void updateWidgets() { if (PreferencesUtils.getBoolean(context, PreferencesUtils.PREF_WIDGET_UNREAD_EXISTS, false)) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] ids = appWidgetManager.getAppWidgetIds(new ComponentName(context, UnreadAppWidgetProvider.class)); Intent intent = new Intent(context, UnreadAppWidgetProvider.class); intent.setAction("android.appwidget.action.APPWIDGET_UPDATE"); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); context.sendBroadcast(intent);/*w ww. ja v a2s.c o m*/ Log.d(TAG, "Widget update Intent fired"); } }
From source file:org.kaoriha.phonegap.plugins.releasenotification.Notifier.java
private void pollBackground() { if (getToken() == null) { rescheduleAfterFail();/*w w w . ja v a2s. c o m*/ return; } ToNextReleasePolling tp = new ToNextReleasePolling(); tp.poll(); if (tp.isFailed) { Log.d(TAG, "ToNextReleasePolling failed"); rescheduleAfterFail(); return; } CataloguePolling cp = new CataloguePolling(); cp.poll(); if (cp.isFailed) { Log.d(TAG, "CataloguePolling failed"); rescheduleAfterFail(); return; } if (!cp.isNew) { if (tp.toNextRelease == -1) { schedule(RESCHEDULE_NEXT_UNKNOWN_SPAN); } else { schedule(tp.toNextRelease); } Log.d(TAG, "CataloguePolling not new"); return; } String pushMessage; if (cp.catalogue.has(CATALOGUE_PUSH_MESSAGE_KEY)) { try { pushMessage = cp.catalogue.getString(CATALOGUE_PUSH_MESSAGE_KEY); } catch (JSONException e) { Log.i(TAG, "pollBackground()", e); pushMessage = pref.getString(SPKEY_DEFAULT_PUSH_MESSAGE, null); } } else { pushMessage = pref.getString(SPKEY_DEFAULT_PUSH_MESSAGE, null); } String lastSid; try { lastSid = getLastSid(cp.catalogue); if (lastSid.equals(pref.getString(SPKEY_LAST_SID, null))) { schedule(tp.toNextRelease); } } catch (JSONException e) { Log.d(TAG, "bad JSON", e); rescheduleAfterFail(); return; } int icon = R.drawable.notification; Notification n = new Notification(icon, pushMessage, System.currentTimeMillis()); n.flags = Notification.FLAG_AUTO_CANCEL; Intent i = new Intent(ctx, FlowerflowerActivity.class); i.setAction(Intent.ACTION_MAIN); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(ctx, 0, i, 0); n.setLatestEventInfo(ctx.getApplicationContext(), pref.getString(SPKEY_TITLE, null), pushMessage, pi); NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, n); pref.edit().putString(SPKEY_LAST_SID, lastSid).putString(SPKEY_LAST_CATALOGUE_ETAG, cp.etag).commit(); clearFailRepeat(); schedule(tp.toNextRelease); Log.d(TAG, "pollBackground() success"); }
From source file:com.poinsart.votar.VotarMain.java
@Override protected void onCreate(Bundle savedInstanceState) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); System.loadLibrary("VotAR"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); assetMgr = this.getAssets(); imageView = (ImageView) findViewById(R.id.imageView); bar[0] = (ProgressBar) findViewById(R.id.bar_a); bar[1] = (ProgressBar) findViewById(R.id.bar_b); bar[2] = (ProgressBar) findViewById(R.id.bar_c); bar[3] = (ProgressBar) findViewById(R.id.bar_d); barLabel[0] = (TextView) findViewById(R.id.label_a); barLabel[1] = (TextView) findViewById(R.id.label_b); barLabel[2] = (TextView) findViewById(R.id.label_c); barLabel[3] = (TextView) findViewById(R.id.label_d); wifiLabel = (TextView) findViewById(R.id.label_wifi); mainLayout = ((LinearLayout) findViewById(R.id.mainLayout)); controlLayout = ((LinearLayout) findViewById(R.id.controlLayout)); imageLayout = ((LinearLayout) findViewById(R.id.imageLayout)); adjustLayoutForOrientation(getResources().getConfiguration().orientation); findViewById(R.id.buttonCamera).setOnClickListener(new View.OnClickListener() { @Override// ww w. j ava 2 s . c o m public void onClick(View v) { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraFileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraFileUri); // set the image file name startActivityForResult(cameraIntent, CAMERA_REQUEST); } }); findViewById(R.id.buttonGallery).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), GALLERY_REQUEST); } }); votarwebserver = new VotarWebServer(51285, this); try { votarwebserver.start(); } catch (IOException e) { Log.w("Votar MainAct", "The webserver could not be started, remote display wont be available"); } }
From source file:com.neusou.bioroid.restful.RestfulClient.java
/** * Executes HTTP method//from w ww .j av a 2 s. c om * @param <T> Http Request Method class * @param <V> Restful response class * @param <M> restful method class * @param <R> response handler class * @param httpMethod http request method * @param rh response handler * @param data extra invocation data */ public <T extends HttpRequestBase, V extends IRestfulResponse<?>, M extends RestfulMethod, R extends RestfulResponseHandler<V, M>> void execute( final T httpMethod, R rh, final Bundle data) { Logger.l(Logger.DEBUG, LOG_TAG, "execute() " + httpMethod.getRequestLine().toString()); DefaultHttpClient httpClient = new DefaultHttpClient(); V response = null; String exceptionMessage = null; String cachedResponse = null; boolean isResponseCached = data.getBoolean(KEY_USE_CACHE, mUseCacheByDefault); String requestUrl = httpMethod.getRequestLine().getUri().toString(); Logger.l(Logger.DEBUG, LOG_TAG, "# # # # # useCache? " + isResponseCached); if (mResponseCacheInitialized && isResponseCached) { httpMethod.getParams().setBooleanParameter("param1", true); //Log.d(LOG_TAG, "paramstring: "+paramString); cachedResponse = mCacheResponseDbHelper.getResponse(requestUrl, httpMethod.getMethod()); Logger.l(Logger.DEBUG, LOG_TAG, "# # # # # cached response: " + cachedResponse); response = rh.createResponse(cachedResponse); response.set(new StringReader(cachedResponse)); } if (cachedResponse == null) { try { response = httpClient.execute(httpMethod, rh); } catch (ClientProtocolException e) { e.printStackTrace(); exceptionMessage = e.getMessage(); httpMethod.abort(); } catch (UnknownHostException e) { e.printStackTrace(); exceptionMessage = "not connected to the internet"; httpMethod.abort(); } catch (IOException e) { e.printStackTrace(); exceptionMessage = "connection error. please try again."; httpMethod.abort(); } // cache the response if (exceptionMessage == null && mResponseCacheInitialized && isResponseCached) { Logger.l(Logger.DEBUG, LOG_TAG, "# # # # # inserting response to cache: " + response); M method = data.getParcelable(XTRA_METHOD); BufferedReader br = new BufferedReader(response.get()); StringBuilder sb = new StringBuilder(); char[] buffer = new char[51200]; try { while (true) { int bytesRead; bytesRead = br.read(buffer); if (bytesRead == -1) { break; } sb.append(buffer, 0, bytesRead); } mCacheResponseDbHelper.insertResponse(requestUrl, sb.toString(), Calendar.getInstance().getTime().getTime(), httpMethod.getMethod(), method.getCallId()); } catch (IOException e) { e.printStackTrace(); } } } // process response //Logger.l(Logger.DEBUG, LOG_TAG, "starting service with action: "+INTENT_PROCESS_RESPONSE); Intent processIntent = new Intent(); processIntent.setAction(INTENT_PROCESS_RESPONSE); processIntent.putExtra(XTRA_RESPONSE, response); processIntent.putExtra(XTRA_ERROR, exceptionMessage); processIntent.putExtra(XTRA_REQUEST, data); mContext.startService(processIntent); boolean imcallback = data.getBoolean(KEY_IMMEDIATECALLBACK, false); if (imcallback) { Bundle callbackData = new Bundle(); callbackData.putBundle(XTRA_REQUEST, data); callbackData.putParcelable(XTRA_RESPONSE, response); callbackData.putString(XTRA_ERROR, exceptionMessage); broadcastCallback(mContext, callbackData, generateKey(mContext.getPackageName(), mName, RestfulClient.KEY_CALLBACK_INTENT)); } }
From source file:fr.simon.marquis.preferencesmanager.ui.PreferencesActivity.java
private void createShortcut() { Intent shortcutIntent = new Intent(this, PreferencesActivity.class); shortcutIntent.putExtra(EXTRA_PACKAGE_NAME, packageName); shortcutIntent.putExtra(EXTRA_TITLE, title); shortcutIntent.putExtra(EXTRA_SHORTCUT, true); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); addIntent.setAction(INSTALL_SHORTCUT); sendBroadcast(addIntent);/* ww w . ja v a 2 s . c o m*/ }
From source file:io.selendroid.ServerInstrumentation.java
public void startActivity(Class activity) { if (activity == null) { SelendroidLogger.log("activity class is empty", new NullPointerException("Activity class to start is null.")); return;// w ww .j a v a 2s. c o m } finishAllActivities(); // start now the new activity Intent intent = new Intent(getTargetContext(), activity); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); Activity a = startActivitySync(intent); }
From source file:com.mobicage.rogerthat.registration.YSAAARegistrationActivity.java
private void launchMainActivityAndFinishIfAppReady() { T.UI();//from w w w . j a v a 2 s. c om Friend f = MainActivity.getFriendForYSAAAWhenReady(mService); if (f != null) { mTimer.cancel(); mProgressBar.setProgress(100); mUIHandler.postDelayed(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); Intent intent = new Intent(YSAAARegistrationActivity.this, MainActivity.class); intent.setAction(MainActivity.ACTION_REGISTERED); intent.setFlags(MainActivity.FLAG_CLEAR_STACK); startActivity(intent); YSAAARegistrationActivity.this.finish(); } }, 1000); } }
From source file:com.krayzk9s.imgurholo.ui.MessagingFragment.java
private void selectItem(int position) { Intent intent = new Intent(); JSONParcelable jsonParcelable = new JSONParcelable(); jsonParcelable.setJSONObject(messageAdapter.getItem(position).getJSONObject()); intent.putExtra("data", jsonParcelable); intent.setAction(ImgurHoloActivity.MESSAGE_INTENT); intent.addCategory(Intent.CATEGORY_DEFAULT); startActivity(intent);/* w w w.ja v a 2 s . c o m*/ }
From source file:it.jaschke.alexandria.model.view.BookDetailViewModel.java
/** * Requests {@link BookService} to delete the book for which the detail data * is shown and publishes a {@link BookDeletionEvent} on the {@link EventBus}. * If no book is set, does nothing.//from w w w .j ava 2s . c o m * * @param context the {@link Context} used to comunicate with the * {@link BookService} to request the book's deletion. */ public void deleteBook(Context context) { if (mBook == null) { Log.i(LOG_TAG, "Ignoring deletion request. No book set."); return; } Intent bookIntent = new Intent(context, BookService.class); bookIntent.putExtra(BookService.EXTRA_BOOK, Parcels.wrap(mBook)); bookIntent.setAction(BookService.ACTION_DELETE_BOOK); context.startService(bookIntent); EventBus.getDefault().post(new BookDeletionEvent(mBook)); }