List of usage examples for android.content Intent getAction
public @Nullable String getAction()
From source file:com.flavik.barcode.recognizer.client.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 www . j a v a 2 s . c o m*/ return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { 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.isEmpty()) { // 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:au.com.smarttrace.beacons.BluetoothService.java
@Override public synchronized int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "Starting: " + intent); if (intent == null || ACTION_SCAN.equals(intent.getAction())) { connect();/*from w w w . j a v a2 s . c om*/ } else if (ACTION_RESCAN.equals(intent.getAction())) { reconnect(); } DeviceManager.getInstance().onBluetoothOn(); return START_STICKY; }
From source file:com.hichinaschool.flashcards.anki.StudyOptionsActivity.java
/** * Show/dismiss dialog when sd card is ejected/remounted (collection is saved by SdCardReceiver) *//*ww w .ja v a2 s . co m*/ private void registerExternalStorageListener() { if (mUnmountReceiver == null) { mUnmountReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) { mNotMountedDialog = StyledOpenCollectionDialog.show(StudyOptionsActivity.this, getResources().getString(R.string.sd_card_not_mounted), new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { finish(); } }); } else if (intent.getAction().equals(SdCardReceiver.MEDIA_MOUNT)) { if (mNotMountedDialog != null && mNotMountedDialog.isShowing()) { mNotMountedDialog.dismiss(); } mCurrentFragment.reloadCollection(); } } }; IntentFilter iFilter = new IntentFilter(); iFilter.addAction(SdCardReceiver.MEDIA_EJECT); iFilter.addAction(SdCardReceiver.MEDIA_MOUNT); registerReceiver(mUnmountReceiver, iFilter); } }
From source file:cn.jarlen.media.sample.VideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); Intent intent = getIntent(); String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown scheme\n"); finish();/*from w w w . j a v a2s . c om*/ return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); mMediaController = new AndroidMediaController(this, false); mMediaController.setSupportActionBar(actionBar); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(mMediaController); mVideoView.setHudView(mHudView); // prefer mVideoPath if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } mVideoView.start(); }
From source file:org.kegbot.app.service.CheckinService.java
@Override protected void onHandleIntent(Intent intent) { try {// w w w . j a v a2 s . com final String action = intent.getAction(); if (CHECKIN_ACTION.equals(action)) { doCheckin(); } else if (resetCheckinStateIfNeeded()) { doCheckin(); } } finally { releaseWakeLock(); } }
From source file:com.galois.qrstream.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setupUI();//from w ww. j a v a 2 s . c o m hideUI(); fragmentManager = getFragmentManager(); transmitFragment = new TransmitFragment(); receiveFragment = new ReceiveFragment(); settingsFragment = new SettingsFragment(); // Load application's default settings before user opens settings // screen because we want Rx and Tx to run with defaults. PreferenceManager.setDefaultValues(this, com.galois.qrstream.lib.R.xml.settings, false); if (savedInstanceState == null) { Intent startingIntent = getIntent(); Log.d(Constants.APP_TAG, "startingIntent " + startingIntent.getAction()); if (startingIntent.getAction().equals(Intent.ACTION_SEND)) { try { Job job = buildJobFromIntent(startingIntent); Bundle bundle = new Bundle(); bundle.putSerializable("job", job); transmitFragment.setArguments(bundle); showFragment(transmitFragment); } catch (IllegalArgumentException e) { Toast.makeText(this, "Unsupported media type.", Toast.LENGTH_LONG).show(); finish(); } } else { showFragment(receiveFragment); } } }
From source file:com.google.zxing.client.android.book.SearchBookContentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); fakeR = new FakeR(this); // 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 w w w . j av a2 s. c om*/ return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(fakeR.getId("string", "sbc_name"))); } else { setTitle(getString(fakeR.getId("string", "sbc_name")) + ": ISBN " + isbn); } setContentView(fakeR.getId("layout", "search_book_contents")); queryTextView = (EditText) findViewById(fakeR.getId("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(fakeR.getId("id", "query_button")); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(fakeR.getId("id", "result_list_view")); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(fakeR.getId("layout", "search_book_contents_header"), resultListView, false); resultListView.addHeaderView(headerView); }
From source file:net.gromgull.android.bibsonomyposter.BibsonomyPosterActivity.java
/** Called with the activity is first created. */ @Override// w ww . j a v a 2 s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); load(); Intent intent = getIntent(); String action = intent.getAction(); if (action.equalsIgnoreCase(Intent.ACTION_SEND)) { final String uri = intent.getStringExtra(Intent.EXTRA_TEXT); final String title = intent.getStringExtra(Intent.EXTRA_SUBJECT); final Context context = getApplicationContext(); new AsyncTask<Void, Integer, Boolean>() { @Override protected Boolean doInBackground(Void... v) { try { bookmark(uri, title); return true; } catch (Exception e) { Log.w(LOGTAG, "Could not bookmark: " + title + " / " + uri, e); return false; } } protected void onPostExecute(Boolean result) { if (result) { Toast toast = Toast.makeText(context, "Bookmarked " + title, Toast.LENGTH_SHORT); toast.show(); } else { Toast toast = Toast.makeText(context, "Error bookmarking " + title, Toast.LENGTH_SHORT); toast.show(); } } }.execute(); finish(); return; } // Inflate our UI from its XML layout description. setContentView(R.layout.bibsonomyposter_activity); if (username != null) ((EditText) findViewById(R.id.username)).setText(username); if (apikey != null) ((EditText) findViewById(R.id.apikey)).setText(apikey); // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.save)).setOnClickListener(mSaveListener); }
From source file:com.josephblough.sbt.activities.ShortcutActivity.java
/** Called when the activity is first created. */ @Override//w w w. j av a2 s . co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) { // Create a shortcut //ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); ShortcutAdapter adapter = new ShortcutAdapter(this, R.layout.shortcut_type_row, ITEMS); setListAdapter(adapter); getListView().setOnItemClickListener(this); } else { // Perform the search final int searchType = intent.getIntExtra(SEARCH_TYPE, 0); final String criteria = intent.getStringExtra(CRITERIA); try { performSearch(searchType, criteria); } catch (JSONException e) { Log.e(TAG, e.getMessage(), e); Toast.makeText(this, "There was an error reading search criteria", Toast.LENGTH_LONG).show(); } } }
From source file:de.grobox.blitzmail.SendActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // before doing anything show notification about sending process mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(this); mBuilder.setContentTitle(getString(R.string.sending_mail)).setContentText(getString(R.string.please_wait)) .setSmallIcon(R.drawable.notification_icon).setOngoing(true); // Sets an activity indicator for an operation of indeterminate length mBuilder.setProgress(0, 0, true);/*from www .jav a2 s . c o m*/ // Create Pending Intent notifyIntent = new Intent(this, NotificationHandlerActivity.class); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(pendingIntent); // Issues the notification mNotifyManager.notify(0, mBuilder.build()); Properties prefs; try { prefs = getPrefs(); } catch (Exception e) { String msg = e.getMessage(); Log.i("SendActivity", "ERROR: " + msg, e); if (e.getClass().getCanonicalName().equals("java.lang.RuntimeException") && e.getCause() != null && e.getCause().getClass().getCanonicalName().equals("javax.crypto.BadPaddingException")) { msg = getString(R.string.error_decrypt); } showError(msg); return; } // get and handle Intent Intent intent = getIntent(); String action = intent.getAction(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (action.equals(Intent.ACTION_SEND)) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); //String email = intent.getStringExtra(Intent.EXTRA_EMAIL); String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); String cc = intent.getStringExtra(Intent.EXTRA_CC); String bcc = intent.getStringExtra(Intent.EXTRA_BCC); // Check for empty content if (subject == null && text != null) { // cut all characters from subject after the 128th subject = text.substring(0, (text.length() < 128) ? text.length() : 128); // remove line breaks from subject subject = subject.replace("\n", " ").replace("\r", " "); } else if (subject != null && text == null) { text = subject; } else if (subject == null && text == null) { Log.e("Instant Mail", "Did not send mail, because subject and body empty."); showError(getString(R.string.error_no_body_no_subject)); return; } // create JSON object with mail information mMail = new JSONObject(); try { mMail.put("id", String.valueOf(new Date().getTime())); mMail.put("body", text); mMail.put("subject", subject); mMail.put("cc", cc); mMail.put("bcc", bcc); } catch (JSONException e) { e.printStackTrace(); } // remember mail for later MailStorage.saveMail(this, mMail); // pass mail on to notification dialog class notifyIntent.putExtra("mail", mMail.toString()); // Start Mail Task AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail); mail.execute(); } else if (action.equals("BlitzMailReSend")) { try { mMail = new JSONObject(intent.getStringExtra("mail")); } catch (JSONException e) { e.printStackTrace(); } // pass mail on to notification dialog class notifyIntent.putExtra("mail", mMail.toString()); // Start Mail Task AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail); mail.execute(); } finish(); }