List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:com.moxtra.moxiechat.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras();/* w w w. ja v a 2s .c o m*/ GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message. boolean handled = MXNotificationManager.preProcessMXNotification(getApplicationContext(), intent); if (handled) { // This is a moxtra message and it will be handled by moxtra if (intent.getBooleanExtra(MXNotificationManager.MOXTRA_MESSAGE_SHOW_NOTIFICATION, false)) { String title = intent.getStringExtra(MXNotificationManager.MOXTRA_MESSAGE_TITLE_TEXT); if (intent.hasExtra(MXNotificationManager.MOXTRA_MESSAGE_ALERT_SOUND)) { String soundUrl = intent .getStringExtra(MXNotificationManager.MOXTRA_MESSAGE_ALERT_SOUND); Log.d(TAG, "soundUrl = " + soundUrl); Uri uri = Uri.parse(soundUrl); sendMoxtraNotification(title, uri, intent); } else { sendMoxtraNotification(title, intent); } } } else { // Not a moxtra message and app should handle it. Log.i(TAG, "App should handle it."); } Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java
private SafeBroadcastReceiver getBroadcastReceiver() { return new SafeBroadcastReceiver() { @Override//from w ww . java 2 s .c o m public String[] onSafeReceive(Context context, Intent intent) { T.UI(); if (intent.getAction().equals(FriendsPlugin.FRIEND_INFO_RECEIVED_INTENT)) { final String emailHash = intent.getStringExtra(EMAILHASH); if (emailHash != null && emailHash.equals(mExpectedEmailHash)) { abortProcessing(); if (intent.getBooleanExtra(ProcessScanActivity.SUCCESS, true)) { final Intent inviteFriendIntent = new Intent(ProcessScanActivity.this, InviteFriendActivity.class); // Copy extra from other intent for (String extra : new String[] { AVATAR, DESCRIPTION, DESCRIPTION_BRANDING, EMAIL, EMAILHASH, NAME, QUALIFIED_IDENTIFIER }) { inviteFriendIntent.putExtra(extra, intent.getStringExtra(extra)); } inviteFriendIntent.putExtra(TYPE, intent.getLongExtra(TYPE, FriendsPlugin.FRIEND_TYPE_USER)); startActivity(inviteFriendIntent); finish(); return new String[] { intent.getAction() }; } else { showError(intent); } } else { // ignore } } else if (intent.getAction().equals(FriendsPlugin.SERVICE_ACTION_INFO_RECEIVED_INTENT)) { if (mExpectedEmailHash != null && mExpectedEmailHash.equals(intent.getStringExtra(EMAILHASH)) && mExpectedAction != null && mExpectedAction.equals(intent.getStringExtra(POKE_ACTION))) { abortProcessing(); if (intent.getBooleanExtra(SUCCESS, true)) { final Intent serviceActionIntent = new Intent(ProcessScanActivity.this, ServiceActionActivity.class); // Copy extra from other intent for (String extra : new String[] { AVATAR, DESCRIPTION, DESCRIPTION_BRANDING, EMAIL, NAME, POKE_DESCRIPTION, QUALIFIED_IDENTIFIER, STATIC_FLOW, STATIC_FLOW_HASH }) { serviceActionIntent.putExtra(extra, intent.getStringExtra(extra)); } serviceActionIntent.putExtra(EMAILHASH, mExpectedEmailHash); serviceActionIntent.putExtra(POKE_ACTION, mExpectedAction); serviceActionIntent.setAction(FriendsPlugin.SERVICE_ACTION_INFO_RECEIVED_INTENT); serviceActionIntent.putExtra(SUCCESS, true); startActivity(serviceActionIntent); finish(); // TODO: set success? return new String[] { intent.getAction() }; } else { showError(intent); } } else { // ignore } } else if (intent.getAction().equals(URL_REDIRECTION_DONE)) { final String emailHash = intent.getStringExtra(EMAILHASH); if (intent.hasExtra(POKE_ACTION)) { final String pokeAction = intent.getStringExtra(POKE_ACTION); getServiceActionInfo(emailHash, pokeAction); } else { processEmailHash(emailHash); } return new String[] { intent.getAction() }; } return null; // Intent was ignored } }; }
From source file:com.stasbar.knowyourself.timer.TimerFragment.java
@Override public void onStart() { super.onStart(); // Initialize the page indicators. updatePageIndicators();/*from w ww .ja va2 s . c o m*/ boolean createTimer = false; int showTimerId = -1; // Examine the intent of the parent activity to determine which view to display. final Intent intent = getActivity().getIntent(); if (intent != null) { // These extras are single-use; remove them after honoring them. createTimer = intent.getBooleanExtra(EXTRA_TIMER_SETUP, false); intent.removeExtra(EXTRA_TIMER_SETUP); showTimerId = intent.getIntExtra(TimerService.EXTRA_TIMER_ID, -1); intent.removeExtra(TimerService.EXTRA_TIMER_ID); } // Choose the view to display in this fragment. if (showTimerId != -1) { // A specific timer must be shown; show the list of timers. showTimersView(); } else if (!hasTimers() || createTimer || mTimerSetupState != null) { // No timers exist, a timer is being created, or the last view was timer setup; // show the timer setup view. showCreateTimerView(); if (mTimerSetupState != null) { mCreateTimerView.setState(mTimerSetupState); mTimerSetupState = null; } } else { // Otherwise, default to showing the list of timers. showTimersView(); } // If the intent did not specify a timer to show, show the last timer that expired. if (showTimerId == -1) { final Timer timer = DataModel.getDataModel().getMostRecentExpiredTimer(); showTimerId = timer == null ? -1 : timer.getId(); } // If a specific timer should be displayed, display the corresponding timer tab. if (showTimerId != -1) { final Timer timer = DataModel.getDataModel().getTimer(showTimerId); if (timer != null) { final int index = DataModel.getDataModel().getTimers().indexOf(timer); mViewPager.setCurrentItem(index); } } }
From source file:com.android.deskclock.timer.TimerFragment.java
@Override public void onResume() { super.onResume(); // Start watching for page changes away from this fragment. getDeskClock().registerPageChangedListener(this); // Initialize the page indicators. updatePageIndicators();/*from ww w .j av a 2 s . c om*/ boolean createTimer = false; int showTimerId = -1; // Examine the intent of the parent activity to determine which view to display. final Intent intent = getActivity().getIntent(); if (intent != null) { // These extras are single-use; remove them after honoring them. createTimer = intent.getBooleanExtra(EXTRA_TIMER_SETUP, false); intent.removeExtra(EXTRA_TIMER_SETUP); showTimerId = intent.getIntExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, -1); intent.removeExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID); } // Choose the view to display in this fragment. if (showTimerId != -1) { // A specific timer must be shown; show the list of timers. showTimersView(); } else if (!hasTimers() || createTimer || mTimerSetupState != null) { // No timers exist, a timer is being created, or the last view was timer setup; // show the timer setup view. showCreateTimerView(); if (mTimerSetupState != null) { mCreateTimerView.setState(mTimerSetupState); mTimerSetupState = null; } } else { // Otherwise, default to showing the list of timers. showTimersView(); } // If the intent did not specify a timer to show, show the last timer that expired. if (showTimerId == -1) { final Timer timer = DataModel.getDataModel().getMostRecentExpiredTimer(); showTimerId = timer == null ? -1 : timer.getId(); } // If a specific timer should be displayed, display the corresponding timer tab. if (showTimerId != -1) { final Timer timer = DataModel.getDataModel().getTimer(showTimerId); if (timer != null) { final int index = DataModel.getDataModel().getTimers().indexOf(timer); mViewPager.setCurrentItem(index); } } }
From source file:com.androidquery.simplefeed.activity.ImageActivity.java
@Override protected void init(Bundle savedInstanceState) { initView();/*from w w w .j a v a 2 s . c o m*/ Intent intent = getIntent(); if (intent == null) return; String url = intent.getStringExtra("url"); if (url == null) return; item = (FeedItem) intent.getSerializableExtra("item"); if (item != null) { if ("photo".equals(item.getType())) { url = handle.getNetworkUrl(url); } if (item.getSource() == null) { item.setSource(url); item.setItemName(item.getDesc()); } photos.add(item); adapter.notifyDataSetChanged(); boolean fetchAlbum = intent.getBooleanExtra("album", true); String album = extractAlbum(item); if (fetchAlbum && album != null) { ajaxPhoto(album, HALF_DAY); } } }
From source file:com.sft.fragment.CoachsFragment1.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null) { if (resultCode == R.id.base_left_btn) { return; }/*from ww w . ja v a 2 s .c om*/ boolean isFromEnroll = data.getBooleanExtra(from_searchCoach_enroll, false); if (isFromEnroll) { data.setClass(getActivity(), ApplyActivity.class); data.putExtra(from_searchCoach_enroll, isFromEnroll); startActivity(data); getActivity().finish(); } } }
From source file:com.fbartnitzek.tasteemall.filter.EntityFilterTabFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.v(LOG_TAG, "onActivityResult, hashCode=" + this.hashCode() + ", " + "requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]"); if (requestCode == REQUEST_ATTRIBUTE_FILTER_CODE && resultCode == Activity.RESULT_OK) { if (data.hasExtra(EXTRA_ATTRIBUTE_FILTERED)) { RecyclerView.ViewHolder vh = mAttributesRecycler.findViewHolderForAdapterPosition(mPosition); Log.v(LOG_TAG, "onActivityResult, hashCode=" + this.hashCode() + ", " + "vh=" + vh); // snackbar with all filters for entity...? - not usable for selection... // TODO: store to restore, maybe via jsonFilter... if (data.getBooleanExtra(EXTRA_ATTRIBUTE_FILTERED, false)) { mSelected.add(mPosition); vh.itemView.setBackgroundColor(Color.GREEN); } else { mSelected.remove((Integer) mPosition); vh.itemView.setBackgroundColor(Color.TRANSPARENT); }//from ww w . ja v a 2s . c o m } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.amaze.filemanager.services.ExtractService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle b = new Bundle(); b.putInt("id", startId); epath = PreferenceManager.getDefaultSharedPreferences(this).getString("extractpath", ""); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); String file = intent.getStringExtra("zip"); eentries = intent.getBooleanExtra("entries1", false); if (eentries) { entries = intent.getStringArrayListExtra("entries"); }// w w w . j a v a 2 s .c o m b.putString("file", file); DataPackage intent1 = new DataPackage(); intent1.setName(file); intent1.setTotal(0); intent1.setDone(0); intent1.setId(startId); intent1.setP1(0); intent1.setCompleted(false); hash1.put(startId, intent1); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.putExtra("openprocesses", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(cd); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.extracting)) .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_doc_compressed); hash.put(startId, true); new Doback().execute(b); return START_STICKY; }
From source file:com.mobicage.rogerthat.plugins.messaging.AttachmentViewerActivity.java
@Override protected void onServiceBound() { T.UI();//from w w w. j ava2 s . co m mProgressDialog = new ProgressDialog(AttachmentViewerActivity.this); mProgressDialog.setMessage(mService.getString(R.string.downloading)); mProgressDialog.setIndeterminate(true); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setCancelable(true); mMessagingPlugin = mService.getPlugin(MessagingPlugin.class); final Intent intent = getIntent(); mThreadKey = intent.getStringExtra("thread_key"); mMessageKey = intent.getStringExtra("message"); mContentType = intent.getStringExtra("content_type"); mDownloadUrl = intent.getStringExtra("download_url"); mName = intent.getStringExtra("name"); mDownloadUrlHash = intent.getStringExtra("download_url_hash"); mGenerateThumbnail = intent.getBooleanExtra("generate_thumbnail", false); if (mContentType.toLowerCase(Locale.US).startsWith("video/")) { setContentView(R.layout.file_viewer_video); mVideoview = (VideoView) findViewById(R.id.videoView); } else { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); setContentView(R.layout.file_viewer); mWebview = (WebView) findViewById(R.id.webview); mWebview.setWebChromeClient(new WebChromeClient() { @Override public void onConsoleMessage(String message, int lineNumber, String sourceID) { if (sourceID != null) { try { sourceID = new File(sourceID).getName(); } catch (Exception e) { L.d("Could not get fileName of sourceID: " + sourceID, e); } } L.d(sourceID + ":" + lineNumber + " | " + message); } }); mWebview.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { L.d(failingUrl + ":" + errorCode + " | " + description); } }); final TextView titleTextView = (TextView) findViewById(R.id.title); if (TextUtils.isEmptyOrWhitespace(mName)) { titleTextView.setVisibility(View.GONE); findViewById(R.id.divider).setVisibility(View.GONE); } else { titleTextView.setVisibility(View.VISIBLE); titleTextView.setText(mName); findViewById(R.id.divider).setVisibility(View.VISIBLE); } } try { mAttachmentsDir = mMessagingPlugin.attachmentsDir(mThreadKey, null); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(this, "", R.string.unable_to_read_write_sd_card); return; } mFile = new File(mAttachmentsDir, mDownloadUrlHash); if (mMessagingPlugin.attachmentExists(mAttachmentsDir, mDownloadUrlHash)) { updateView(false); } else { try { mAttachmentsDir = mMessagingPlugin.attachmentsDir(mThreadKey, mMessageKey); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(this, "", R.string.unable_to_read_write_sd_card); return; } mFile = new File(mAttachmentsDir, mDownloadUrlHash); if (mMessagingPlugin.attachmentExists(mAttachmentsDir, mDownloadUrlHash)) { updateView(false); } else { downloadAttachment(); } } }
From source file:com.daiv.android.twitter.services.SendTweet.java
@Override public int onStartCommand(Intent intent, int i, int x) { final Context context = this; final AppSettings settings = AppSettings.getInstance(this); try {/*from ww w . j ava 2s. c o m*/ if (intent == null) { return START_NOT_STICKY; } } catch (Exception e) { // null pointer... what the hell } // set up the tweet from the intent message = intent.getStringExtra("message"); tweetId = intent.getLongExtra("tweet_id", 0l); remainingChars = intent.getIntExtra("char_remaining", 0); pwiccer = intent.getBooleanExtra("pwiccer", false); attachedUri = intent.getStringExtra("attached_uri"); secondAcc = intent.getBooleanExtra("second_account", false); if (attachedUri == null) { attachedUri = ""; } sendingNotification(); new Thread(new Runnable() { @Override public void run() { boolean sent = sendTweet(settings, context); if (sent) { finishedTweetingNotification(); } else { makeFailedNotification(message, settings); } finished = true; stopSelf(); } }).start(); // if it takes longer than 2 mins to preform the sending, then something is wrong and we will just shut it down. new Handler().postDelayed(new Runnable() { @Override public void run() { if (!finished) { stopForeground(true); makeFailedNotification(message, settings); stopSelf(); } } }, 120000); return START_STICKY; }