List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.master.metehan.filtereagle.ActivityMain.java
private void checkExtras(Intent intent) { // Approve request if (intent.hasExtra(EXTRA_APPROVE)) { Log.i(TAG, "Requesting VPN approval"); swEnabled.toggle();// ww w .jav a2s . c o m } if (intent.hasExtra(EXTRA_LOGCAT)) { Log.i(TAG, "Requesting logcat"); Intent logcat = getIntentLogcat(); if (logcat.resolveActivity(getPackageManager()) != null) startActivityForResult(logcat, REQUEST_LOGCAT); } }
From source file:com.code.android.vibevault.SearchScreen.java
/** Called when the activity is first created. */ @Override//from w ww.j av a 2 s.c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_screen); this.searchList = (ListView) this.findViewById(R.id.ResultsListView); this.artistSearchInput = (AutoCompleteTextView) this.findViewById(R.id.ArtistSearchBox); this.yearSearchInput = (EditText) this.findViewById(R.id.YearSearchBox); this.dateModifierSpinner = (Spinner) this.findViewById(R.id.DateSearchSpinner); this.searchButton = (Button) this.findViewById(R.id.SearchButton); this.settingsButton = (Button) this.findViewById(R.id.SettingsButton); //this.searchMoreButton = (Button) this.findViewById(R.id.SearchMoreButton); this.clearButton = (Button) this.findViewById(R.id.ClearButton); this.searchDrawer = (SlidingDrawer) this.findViewById(R.id.SlidingDrawerSearchScreen); this.handleText = (TextView) this.findViewById(R.id.HandleTextView); vibrator = (Vibrator) this.getSystemService(VIBRATOR_SERVICE); searchList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Show"); menu.add(Menu.NONE, VibeVault.SHOW_INFO, Menu.NONE, "Show Info"); menu.add(Menu.NONE, VibeVault.ADD_TO_FAVORITE_LIST, Menu.NONE, "Bookmark Show"); } }); Object retained = getLastNonConfigurationInstance(); if (retained instanceof JSONQueryTask) { workerTask = (JSONQueryTask) retained; workerTask.setActivity(this); } else { workerTask = new JSONQueryTask(this); } if (VibeVault.searchResults.size() != 0) { searchButton.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.morebutton), null, null, null); searchButton.setText("More"); //this.clearButton.setEnabled(true); } else { searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.searchbutton_plain), null, null, null); searchButton.setText("Search"); } this.init(); Intent intent = getIntent(); if (intent.hasExtra("Artist")) { browseArtist(intent.getStringExtra("Artist")); } if (!VibeVault.db.getPref("artistUpdate").equals("2010-01-01")) { artistSearchInput.setAdapter( new ArrayAdapter<String>(this, R.layout.artist_search_row, VibeVault.db.getArtistsStrings())); } if (VibeVault.searchPref.equals("Show/Artist Description") && artistSearchInput.getText().equals("")) { artistSearchInput.setHint("Search Descriptions..."); } }
From source file:com.owncloud.android.services.OperationsService.java
/** * Entry point to add a new operation to the queue of operations. * * New operations are added calling to startService(), resulting in a call to this method. * This ensures the service will keep on working although the caller activity goes away. *//*from ww w . ja va 2 s.c om*/ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); // WIP: for the moment, only SYNC_FOLDER is expected here; // the rest of the operations are requested through the Binder if (ACTION_SYNC_FOLDER.equals(intent.getAction())) { if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_REMOTE_PATH)) { Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); String remotePath = intent.getStringExtra(EXTRA_REMOTE_PATH); Pair<Account, String> itemSyncKey = new Pair<>(account, remotePath); Pair<Target, RemoteOperation> itemToQueue = newOperation(intent); if (itemToQueue != null) { mSyncFolderHandler.add(account, remotePath, (SynchronizeFolderOperation) itemToQueue.second); Message msg = mSyncFolderHandler.obtainMessage(); msg.arg1 = startId; msg.obj = itemSyncKey; mSyncFolderHandler.sendMessage(msg); } } else { Message msg = mOperationsHandler.obtainMessage(); msg.arg1 = startId; mOperationsHandler.sendMessage(msg); } return START_NOT_STICKY; }
From source file:com.shafiq.myfeedle.core.StatusDialog.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(Widgets.INSTANT_UPLOAD)) { mFilePath = intent.getStringExtra(Widgets.INSTANT_UPLOAD); Log.d(TAG, "upload photo?" + mFilePath); } else {//from w w w . j ava 2 s .c o m mData = intent.getData(); if (mData != null) { mData = intent.getData(); if (intent.hasExtra(LauncherIntent.Extra.Scroll.EXTRA_SOURCE_BOUNDS)) mRect = intent.getParcelableExtra(LauncherIntent.Extra.Scroll.EXTRA_SOURCE_BOUNDS); else mRect = intent.getSourceBounds(); Log.d(TAG, "data:" + mData.toString()); // need to use a thread here to avoid anr mLoadingDialog = new ProgressDialog(this); mLoadingDialog.setMessage(getString(R.string.status_loading)); mLoadingDialog.setCancelable(true); mLoadingDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { if (mStatusLoader != null) mStatusLoader.cancel(true); finish(); } }); mLoadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); finish(); } }); mLoadingDialog.show(); mStatusLoader = new StatusLoader(); mStatusLoader.execute(); } } } if (mFilePath != null) { mDialog = (new AlertDialog.Builder(this)).setTitle(R.string.uploadprompt) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivityForResult( Myfeedle.getPackageIntent(getApplicationContext(), MyfeedleCreatePost.class) .putExtra(Widgets.INSTANT_UPLOAD, mFilePath), RESULT_REFRESH); dialog.dismiss(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); StatusDialog.this.finish(); } }).create(); mDialog.show(); } else { // check if the dialog is still loading if (mFinish) finish(); else if ((mLoadingDialog == null) || !mLoadingDialog.isShowing()) showDialog(); } }
From source file:com.sean.takeastand.alarmprocess.AlarmService.java
private void beginStandNotifications(Intent intent) { mainActivityVisible = false;// w w w.j a v a 2 s. co m mHandler = new Handler(); checkMainActivityVisible(); sendNotification(); int defaultReminderTime = Utils.getNotificationReminderFrequency(AlarmService.this) * Constants.secondsInMinute * Constants.millisecondsInSecond; mHandler.postDelayed(timeToUpdateNotification, defaultReminderTime); if (intent.hasExtra(Constants.ALARM_SCHEDULE)) { mCurrentAlarmSchedule = intent.getParcelableExtra(Constants.ALARM_SCHEDULE); } if (mCurrentAlarmSchedule == null) { Utils.setImageStatus(this, Constants.NON_SCHEDULE_TIME_TO_STAND); } else { Utils.setImageStatus(this, Constants.SCHEDULE_TIME_TO_STAND); } }
From source file:com.cerema.cloud2.files.InstantUploadBroadcastReceiver.java
private void handleConnectivityAction(Context context, Intent intent) { if (!instantPictureUploadEnabled(context)) { Log_OC.d(TAG, "Instant upload disabled, don't upload anything"); return;//w w w .j a va2s .c o m } if (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context)) { Account account = AccountUtils.getCurrentOwnCloudAccount(context); if (account == null) { Log_OC.w(TAG, "No account found for instant upload, aborting"); return; } Intent i = new Intent(context, FileUploader.class); i.putExtra(FileUploader.KEY_ACCOUNT, account); i.putExtra(FileUploader.KEY_CANCEL_ALL, true); context.startService(i); } if (!intent.hasExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY) && isOnline(context) && (!instantPictureUploadViaWiFiOnly(context) || (instantPictureUploadViaWiFiOnly(context) == isConnectedViaWiFi(context) == true))) { DbHandler db = new DbHandler(context); Cursor c = db.getAwaitingFiles(); if (c.moveToFirst()) { do { if (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context)) { break; } String account_name = c.getString(c.getColumnIndex("account")); String file_path = c.getString(c.getColumnIndex("path")); File f = new File(file_path); if (f.exists()) { Account account = new Account(account_name, MainApp.getAccountType()); String mimeType = null; try { mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension( f.getName().substring(f.getName().lastIndexOf('.') + 1)); } catch (Throwable e) { Log_OC.e(TAG, "Trying to find out MIME type of a file without extension: " + f.getName()); } if (mimeType == null) mimeType = "application/octet-stream"; Intent i = new Intent(context, FileUploader.class); i.putExtra(FileUploader.KEY_ACCOUNT, account); i.putExtra(FileUploader.KEY_LOCAL_FILE, file_path); i.putExtra(FileUploader.KEY_REMOTE_FILE, FileStorageUtils.getInstantUploadFilePath(context, f.getName())); i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE); i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true); // instant upload behaviour i = addInstantUploadBehaviour(i, context); context.startService(i); } else { Log_OC.w(TAG, "Instant upload file " + f.getAbsolutePath() + " dont exist anymore"); } } while (c.moveToNext()); } c.close(); db.close(); } }
From source file:com.openerp.addons.messages.MessageComposeActivty.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_message_compose); scope = new AppScope((MainActivity) MainActivity.context); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); Intent replyIntent = getIntent(); receipients_view = (TagsView) findViewById(R.id.receipients_view); partner_adapter = new ReceipientsTagsCustomAdapter(this, R.layout.message_receipient_item_layout, parters); receipients_view.setAdapter(partner_adapter); /* tags component */ if (replyIntent.hasExtra("send_reply")) { is_reply = true;/* w w w . j av a 2 s . co m*/ } else { parters.addAll(getAllPartners()); } receipients_view.setPrefix("To: "); receipients_view.allowDuplicates(false); receipients_view.setTokenListener(this); if (is_reply) { message_id = replyIntent.getExtras().getInt("message_id"); MessageDBHelper msgDb = new MessageDBHelper(this); parent_row = ((List<HashMap<String, Object>>) msgDb.search(msgDb, new String[] { "id = ?" }, new String[] { message_id + "" }).get("records")).get(0); getActionBar().setTitle("?"); EditText edtSubject = (EditText) findViewById(R.id.edtMessageSubject); edtSubject.setText("?: " + parent_row.get("subject").toString()); JSONArray partner_ids = new JSONArray(); try { List<TagsItems> partners = getPartnersOfMessage(message_id + ""); for (TagsItems item : partners) { selectedPartners.put("key_" + item.getId(), item); partner_ids.put(item.getId()); receipients_view.addObject(item); findViewById(R.id.edtMessageBody).requestFocus(); } parent_row.put("partners", partner_ids); } catch (Exception e) { e.printStackTrace(); } } else { getActionBar().setTitle("??"); if (getIntent().getData() != null) { Cursor cursor = managedQuery(getIntent().getData(), null, null, null, null); if (cursor.moveToNext()) { int partner_id = cursor.getInt(cursor.getColumnIndex("data2")); List<TagsItems> partners = getPartnersByIds(Arrays.asList(new Integer[] { partner_id })); for (TagsItems item : partners) { selectedPartners.put("key_" + item.getId(), item); receipients_view.addObject(item); findViewById(R.id.edtMessageSubject).requestFocus(); } } } } lstAttachments = (ListView) findViewById(R.id.lstAttachments); String[] from = new String[] { "name" }; int[] to = new int[] { R.id.txvFileName }; lstAttachmentAdapter = new OEListViewAdapter(MainActivity.context, R.layout.message_attachment_listview_item, attachments, from, to, null); lstAttachments.setAdapter(lstAttachmentAdapter); lstAttachmentAdapter.setItemClickListener(R.id.imgBtnRemoveAttachment, new ControlClickEventListener() { @Override public OEListViewRows controlClicked(int position, OEListViewRows row, View view) { file_uris.remove(position); attachments.remove(position); lstAttachmentAdapter.refresh(attachments); return null; } }); Res_PartnerDBHelper partners = new Res_PartnerDBHelper(this); HashMap<String, Object> data = partners.search(partners); if ((Integer) data.get("total") > 0) { for (HashMap<String, Object> row : (List<HashMap<String, Object>>) data.get("records")) { OEListViewRows newRow = new OEListViewRows(Integer.parseInt(row.get("id").toString()), row); partners_list.add(newRow); } } handleIntentFilter(getIntent()); }
From source file:com.google.android.gcm.demo.app.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); ctx = context;/* ww w . j a v a 2s. co m*/ String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + intent.getExtras().toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + intent.getExtras().toString()); } else { sendNotification("Received: " + intent.getExtras().toString()); // "urn":"soundcloud:sounds:125","finished_at":"0001-01-01T00:00:00Z","last_played_at":"0001-01-01T00:00:00Z","progress":0} LLQueue queue = LLQueue.get(); if (queue == null) return; //queue.loadListenLaterQueue(); if (intent.hasExtra("set")) { String set = intent.getStringExtra("set"); try { JSONObject obj = new JSONObject(set); String urn = obj.optString("urn"); Log.d(TAG, "GCM set with urn:" + urn); if (!TextUtils.isEmpty(urn)) { queue.addUrn(urn); } } catch (JSONException e) { Log.w(TAG, e); } } else if (intent.hasExtra("delete")) { String delete = intent.getStringExtra("delete"); try { JSONObject obj = new JSONObject(delete); String urn = obj.optString("urn"); Log.d(TAG, "GCM set with urn:" + urn); if (!TextUtils.isEmpty(urn)) { queue.removeUrn(urn); } } catch (JSONException e) { Log.w(TAG, e); } } else if (intent.hasExtra("play")) { String play = intent.getStringExtra("play"); try { JSONObject obj = new JSONObject(play); String urn = obj.optString("urn"); String toggleAt = obj.optString("toggle_at"); long progress = obj.optInt("progress", 0); Log.d(TAG, "GCM play with urn:" + urn + " ,togglet_at:" + toggleAt); Intent playIntent = new Intent(); queue.playUrn(urn, progress); if (!TextUtils.isEmpty(toggleAt)) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");//spec for RFC3339 (with fractional seconds) try { Date date = format.parse(toggleAt); Log.d(TAG, "parsed date:" + date); // AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // alarmManager.set(AlarmManager.RTC_WAKEUP, date.getTime(), PendingIntent.getActivity(context, 0, playIntent, 0)); } catch (ParseException e) { Log.w(TAG, e); } } else { } } catch (JSONException e) { Log.w(TAG, e); } } } setResultCode(Activity.RESULT_OK); }
From source file:com.quarterfull.newsAndroid.NewsDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { ThemeChooser.chooseTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_news_detail); ButterKnife.bind(this); if (toolbar != null) { setSupportActionBar(toolbar);/*from w ww . j ava 2 s . co m*/ } pDelayHandler = new PostDelayHandler(this); dbConn = new DatabaseConnectionOrm(this); Intent intent = getIntent(); //long subsciption_id = -1; //long folder_id = -1; int item_id = 0; //if(intent.hasExtra(NewsReaderDetailActivity.SUBSCRIPTION_ID)) // subsciption_id = intent.getExtras().getLong(NewsReaderDetailActivity.SUBSCRIPTION_ID); //if(intent.hasExtra(NewsReaderDetailActivity.FOLDER_ID)) // folder_id = intent.getExtras().getLong(NewsReaderDetailActivity.FOLDER_ID); if (intent.hasExtra(NewsReaderListActivity.ITEM_ID)) item_id = intent.getExtras().getInt(NewsReaderListActivity.ITEM_ID); if (intent.hasExtra(NewsReaderListActivity.TITEL)) getSupportActionBar().setTitle(intent.getExtras().getString(NewsReaderListActivity.TITEL)); //getActionBar().setTitle(intent.getExtras().getString(NewsReaderDetailActivity.TITEL)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); //if(intent.hasExtra(DATABASE_IDS_OF_ITEMS)) // databaseItemIds = intent.getIntegerArrayListExtra(DATABASE_IDS_OF_ITEMS); rssItems = dbConn.getCurrentRssItemView(-1); //If the Activity gets started from the Widget, read the item id and get the selected index in the cursor. if (intent.hasExtra(WidgetProvider.RSS_ITEM_ID)) { long rss_item_id = intent.getExtras().getLong(WidgetProvider.RSS_ITEM_ID); for (RssItem rssItem : rssItems) { if (rss_item_id == rssItem.getId()) { getSupportActionBar().setTitle(rssItem.getTitle()); break; } else item_id++; } } // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); progressIndicator.setMax(mSectionsPagerAdapter.getCount()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); try { mViewPager.setCurrentItem(item_id, true); PageChanged(item_id); } catch (Exception ex) { ex.printStackTrace(); } mViewPager.addOnPageChangeListener(onPageChangeListener); //Init ChromeCustomTabs mCustomTabsSupported = bindCustomTabsService(); }
From source file:com.master.metehan.filtereagle.ActivityLog.java
private void handleExportPCAP(final Intent data) { new AsyncTask<Object, Object, Throwable>() { @Override/* w w w.ja v a 2 s .c o m*/ protected Throwable doInBackground(Object... objects) { OutputStream out = null; FileInputStream in = null; try { // Stop capture ServiceSinkhole.setPcap(false, ActivityLog.this); Uri target = data.getData(); if (data.hasExtra("org.openintents.extra.DIR_PATH")) target = Uri.parse(target + "/netguard.pcap"); Log.i(TAG, "Export PCAP URI=" + target); out = getContentResolver().openOutputStream(target); File pcap = new File(getCacheDir(), "netguard.pcap"); in = new FileInputStream(pcap); int len; long total = 0; byte[] buf = new byte[4096]; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); total += len; } Log.i(TAG, "Copied bytes=" + total); return null; } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityLog.this); return ex; } finally { if (out != null) try { out.close(); } catch (IOException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } if (in != null) try { in.close(); } catch (IOException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } // Resume capture SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityLog.this); if (prefs.getBoolean("pcap", false)) ServiceSinkhole.setPcap(true, ActivityLog.this); } } @Override protected void onPostExecute(Throwable ex) { if (ex == null) Toast.makeText(ActivityLog.this, R.string.msg_completed, Toast.LENGTH_LONG).show(); else Toast.makeText(ActivityLog.this, ex.toString(), Toast.LENGTH_LONG).show(); } }.execute(); }