List of usage examples for android.os Bundle toString
@Override public synchronized String toString()
From source file:com.royer.bangstopwatch.app.StopwatchFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log.d(TAG, "Enter onActivityCreated..."); InitTimeDisplayView();/*from w w w . j a v a 2s . c om*/ mLapList = (ListView) getView().findViewById(R.id.listLap); this.registerForContextMenu(mLapList); btnStart = (Button) getView().findViewById(R.id.btnStart); btnStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (state == STATE_NONE) { // detect does device support record ? if (AudioRecord.getMinBufferSize(44100, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT) < 0) { Context context = getActivity().getApplicationContext(); Toast toast = Toast.makeText(context, R.string.strNoRecorder, 5); toast.show(); return; } AudioManager audiomanager = (AudioManager) getActivity() .getSystemService(Context.AUDIO_SERVICE); Log.d(TAG, "AudioMode = " + audiomanager.getMode()); if (audiomanager.getMode() != AudioManager.MODE_NORMAL) { Context context = getActivity().getApplicationContext(); Toast toast = Toast.makeText(context, R.string.strInCalling, 5); toast.show(); return; } state = STATE_COUNTDOWN; DialogFragment newFragment = CountdownDialog.NewInstance(5, getTag()); newFragment.show(getFragmentManager(), "countdownDialog"); } else { changeState(); state = STATE_NONE; updateRealElapseTime(); printTime(); // unBind Recordservice if (mBound) { mService.stopRecord(); mService.unsetBang(); getActivity().unbindService(mConnection); getActivity().stopService(new Intent(getActivity(), RecordService.class)); mBound = false; } } ((MainActivity) getActivity()).EnableTab(1, state == STATE_NONE); } }); if (savedInstanceState != null) { Log.d(TAG, "savedInstanceState " + savedInstanceState.toString()); _timekeeper = savedInstanceState.getParcelable(STATE_TIMEKEEPER); mLapManager = savedInstanceState.getParcelable(STATE_LAPS); state = savedInstanceState.getInt(STATE_STATE); mBound = savedInstanceState.getBoolean(STATE_BOUNDING); ((MainActivity) getActivity()).EnableTab(1, state == STATE_NONE); } else { Log.d(TAG, "savedInstanceState == NULL"); if (_timekeeper == null) _timekeeper = new Timekeeper(); if (mLapManager == null) mLapManager = new LapManager(); } InitLapList(); printTime(); updateState(); Log.d(TAG, "Leave OnActivityCreated..."); }
From source file:com.xandy.calendar.AllInOneActivity.java
@Override protected void onCreate(Bundle icicle) { if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) { setTheme(R.style.CalendarTheme_WithActionBarWallpaper); }//from w w w . j av a 2s . c o m super.onCreate(icicle); if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) { mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS); } // Launch add google account if this is first time and there are no // accounts yet if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) { mHandler = new QueryHandler(this.getContentResolver()); mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null, null /* selection args */, null /* sort order */); } // This needs to be created before setContentView mController = CalendarController.getInstance(this); // Get time from intent or icicle long timeMillis = -1; int viewType = -1; final Intent intent = getIntent(); if (icicle != null) { timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME); viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1); } else { String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { // Open EventInfo later timeMillis = parseViewAction(intent); } if (timeMillis == -1) { timeMillis = Utils.timeFromIntentInMillis(intent); } } if (viewType == -1 || viewType > ViewType.MAX_VALUE) { viewType = Utils.getViewTypeFromIntentAndSharedPref(this); } mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater); Time t = new Time(mTimeZone); t.set(timeMillis); if (DEBUG) { if (icicle != null && intent != null) { Log.d(TAG, "both, icicle:" + icicle.toString() + " intent:" + intent.toString()); } else { Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent); } } Resources res = getResources(); mHideString = res.getString(R.string.hide_controls); mShowString = res.getString(R.string.show_controls); mOrientation = res.getConfiguration().orientation; if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) { mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width); if (mControlsParams == null) { mControlsParams = new LayoutParams(mControlsAnimateWidth, 0); } mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else { // Make sure width is in between allowed min and max width values mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100, (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width)); mControlsAnimateWidth = Math.min(mControlsAnimateWidth, (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width)); } mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height); mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true); mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config); mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month); mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls); mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda); mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen); mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen); mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time); Utils.setAllowWeekForDetailView(mIsMultipane); // setContentView must be called before configureActionBar setContentView(R.layout.all_in_one); if (mIsTabletConfig) { mDateRange = (TextView) findViewById(R.id.date_bar); mWeekTextView = (TextView) findViewById(R.id.week_num); } else { mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null); } // configureActionBar auto-selects the first tab you add, so we need to // call it before we set up our own fragments to make sure it doesn't // overwrite us configureActionBar(viewType); mHomeTime = (TextView) findViewById(R.id.home_time); mMiniMonth = findViewById(R.id.mini_month); if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) { mMiniMonth.setLayoutParams( new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight)); } mCalendarsList = findViewById(R.id.calendar_list); mMiniMonthContainer = findViewById(R.id.mini_month_container); mSecondaryPane = findViewById(R.id.secondary_pane); // Must register as the first activity because this activity can modify // the list of event handlers in it's handle method. This affects who // the rest of the handlers the controller dispatches to are. mController.registerFirstEventHandler(HANDLER_KEY, this); initFragments(timeMillis, viewType, icicle); // Listen for changes that would require this to be refreshed SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); mContentResolver = getContentResolver(); }
From source file:in.ceeq.services.CommandService.java
@Override protected void onHandleIntent(Intent intent) { Utils.d("Received command..."); Bundle extras = intent.getExtras(); gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); String senderAddress = extras.getString(SENDER_ADDRESS); commandType = extras.getInt(ACTION); Utils.d("Command Type... " + commandType); switch (commandType) { case SIREN_ON: startSiren();/*from w w w . j a va2 s . com*/ break; case SIREN_OFF: stopRinger(); break; case RINGER_ON: startRinger(); break; case RINGER_OFF: stopRinger(); break; case BACKUP: backup(); break; case ENABLE_TRACKER: Intent tracker = new Intent(this, TrackerService.class); startService(tracker); break; case WIPE: Utils.completeWipe(this); break; case LOCK: break; case GET_LOCATION_FOR_PROTECT: Intent getProtect = new Intent(this, LocationService.class); getProtect.putExtra(ACTION, RequestType.PROTECT); startService(getProtect); break; case GET_LOCATION_FOR_MESSAGE: Intent getLocation = new Intent(this, LocationService.class); getLocation.putExtra(ACTION, RequestType.MESSAGE).putExtra(SENDER_ADDRESS, senderAddress); startService(getLocation); break; case GET_LOCATION_FOR_CURRENT_DETAILS_MESSAGE: Intent getNowLocation = new Intent(this, LocationService.class); getNowLocation.putExtra(ACTION, RequestType.NOW).putExtra(SENDER_ADDRESS, senderAddress); startService(getNowLocation); break; case GET_LOCATION_FOR_BLIP: Intent getBlip = new Intent(this, LocationService.class); getBlip.putExtra(ACTION, RequestType.BLIP); startService(getBlip); break; case SEND_BLIP_TO_SERVER: break; case SEND_LOCATION_TO_SERVER: break; case SEND_CALLS_DETAILS_MESSAGE: Utils.sendMessage(this, senderAddress, Utils.CALLS_M); break; case SEND_CURRENT_DETAILS_MESSAGE: Utils.sendMessage(this, senderAddress, Utils.NOW_M); break; case SEND_CURRENT_LOCATION_MESSAGE: Utils.sendMessage(this, senderAddress, Utils.LOCATION_M); break; case SEND_NEW_LOCATION_MESSAGE: Utils.sendMessage(this, senderAddress, Utils.NEW_LOCATION_M); break; case SEND_PROTECT_MESSAGE: Utils.sendMessage(this, Utils.getStringPrefs(this, Utils.EMERGENCY_CONTACT_NUMBER), Utils.PROTECT_ME_M); case SEND_SIM_CHANGE_MESSAGE: Utils.sendMessage(this, Utils.getStringPrefs(this, Utils.EMERGENCY_CONTACT_NUMBER), Utils.SIM_CHANGE_M); Utils.lock(this); break; case SEND_PIN_FAIL_MESSAGE: Utils.sendMessage(this, senderAddress, Utils.FAIL_M); break; default: break; } if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { } } CloudMessagesReceiver.completeWakefulIntent(intent); MobileMessagesReceiver.completeWakefulIntent(intent); }
From source file:com.android.calendar.AllInOneActivity.java
@Override protected void onCreate(Bundle icicle) { if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) { setTheme(R.style.CalendarTheme_WithActionBarWallpaper); }/*from w w w . j ava 2 s. c o m*/ super.onCreate(icicle); dynamicTheme.onCreate(this); if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) { mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS); } // Launch add google account if this is first time and there are no // accounts yet if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) { mHandler = new QueryHandler(this.getContentResolver()); mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null, null /* selection args */, null /* sort order */); } // This needs to be created before setContentView mController = CalendarController.getInstance(this); // Check and ask for most needed permissions checkAppPermissions(); // Get time from intent or icicle long timeMillis = -1; int viewType = -1; final Intent intent = getIntent(); if (icicle != null) { timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME); viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1); } else { String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { // Open EventInfo later timeMillis = parseViewAction(intent); } if (timeMillis == -1) { timeMillis = Utils.timeFromIntentInMillis(intent); } } if (viewType == -1 || viewType > ViewType.MAX_VALUE) { viewType = Utils.getViewTypeFromIntentAndSharedPref(this); } mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater); Time t = new Time(mTimeZone); t.set(timeMillis); if (DEBUG) { if (icicle != null && intent != null) { Log.d(TAG, "both, icicle:" + icicle.toString() + " intent:" + intent.toString()); } else { Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent); } } Resources res = getResources(); mHideString = res.getString(R.string.hide_controls); mShowString = res.getString(R.string.show_controls); mOrientation = res.getConfiguration().orientation; if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) { mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width); if (mControlsParams == null) { mControlsParams = new LayoutParams(mControlsAnimateWidth, 0); } mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else { // Make sure width is in between allowed min and max width values mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100, (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width)); mControlsAnimateWidth = Math.min(mControlsAnimateWidth, (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width)); } mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height); mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true); mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config); mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month); mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls); mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda); mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen); mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen); mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time); Utils.setAllowWeekForDetailView(mIsMultipane); // setContentView must be called before configureActionBar setContentView(R.layout.all_in_one_material); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mNavigationView = (NavigationView) findViewById(R.id.navigation_view); mFab = (FloatingActionButton) findViewById(R.id.floating_action_button); if (mIsTabletConfig) { mDateRange = (TextView) findViewById(R.id.date_bar); mWeekTextView = (TextView) findViewById(R.id.week_num); } else { mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null); } setupToolbar(viewType); setupNavDrawer(); setupFloatingActionButton(); mHomeTime = (TextView) findViewById(R.id.home_time); mMiniMonth = findViewById(R.id.mini_month); if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) { mMiniMonth.setLayoutParams( new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight)); } mCalendarsList = findViewById(R.id.calendar_list); mMiniMonthContainer = findViewById(R.id.mini_month_container); mSecondaryPane = findViewById(R.id.secondary_pane); // Must register as the first activity because this activity can modify // the list of event handlers in it's handle method. This affects who // the rest of the handlers the controller dispatches to are. mController.registerFirstEventHandler(HANDLER_KEY, this); initFragments(timeMillis, viewType, icicle); // Listen for changes that would require this to be refreshed SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); mContentResolver = getContentResolver(); }
From source file:com.example.isaac.nileswestlitcenter.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); 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 /*/* ww w .j a v a 2s . c o m*/ * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. } if (extras.getString("subject") != null) { if (intent.getExtras().getString("delete") != null) { if (((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode()) { //delete from arraylist for (int i = 0; i < storeWhileScreenOff.size(); i++) { if (storeWhileScreenOff.get(i)[1] == extras.getString("subject") && storeWhileScreenOff.get(i)[2] == extras.getString("name")) { storeWhileScreenOff.remove(i); return; } } //not in stored list, but on screen storeWhileScreenOff.add( new String[] { "true", extras.getString("subject"), extras.getString("name") }); } else { sendMessage(true, extras.getString("subject"), extras.getString("name")); // MainActivity.deleteStudentFromList(extras.getString("subject"),extras.getString("name")); // or MainActivity.delete(extras.getInt("id")); } } else { if (((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode()) { storeWhileScreenOff.add( new String[] { "false", extras.getString("subject"), extras.getString("name") }); } else { sendMessage(false, extras.getString("subject"), extras.getString("name")); } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. sendNotification(extras.getString("subject"), extras.getString("name")); Vibrator v = (Vibrator) this.getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds v.vibrate(1000); ((PowerManager) getSystemService(POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG") .acquire(); Log.i(TAG, "Received: " + extras.toString()); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.abbiya.broadr.gcm.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { JobManager jobManager = BroadrApp.getInstance().getJobManager(); Bundle extras = intent.getExtras(); 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 /*//from w ww . ja v a 2s . c o m * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //retry sending String messageId = (String) extras.get("google.message_id"); String uuid = null; Integer msgType = null; if (messageId != null) { if (messageId.startsWith(Constants.MESSAGE_PREFIX)) { uuid = messageId.substring(Constants.MESSAGE_PREFIX.length(), messageId.length()); msgType = Constants.MESSAGE; } else if (messageId.startsWith(Constants.COMMENT_PREFIX)) { uuid = messageId.substring(Constants.COMMENT_PREFIX.length(), messageId.length()); msgType = Constants.COMMENT; } else if (messageId.startsWith(Constants.GCM_REGISTRATION)) { String email = BroadrApp.getSharedPreferences().getString(Constants.USER_EMAIL, ""); jobManager.addJobInBackground( new SendRegistrationMessageJob(email, UUID.randomUUID().toString())); } else if (messageId != null && messageId.startsWith(Constants.LOCATION_PREFIX)) { String geoHash = LocationUtils.getGeoHash(); GeoHash from = GeoHash.fromGeohashString(geoHash); WGS84Point point = from.getPoint(); Double startLatitude = point.getLatitude(); Double startLongitude = point.getLongitude(); SharedPreferences sharedPreferences = BroadrApp.getSharedPreferences(); String address = sharedPreferences.getString(Constants.LAST_KNOWN_ADDRESS, ""); jobManager.addJobInBackground(new SendLocationJob(String.valueOf(startLatitude), String.valueOf(startLongitude), address, UUID.randomUUID().toString())); } } if (uuid != null) { if (msgType == Constants.MESSAGE) { MessageRepo messageRepo = BroadrApp.getMessageRepo(); Message message = messageRepo.getMessage(uuid); if (message != null) { jobManager.addJobInBackground( new SendMessageJob(message.getId(), message.getContent(), message.getUuid())); } } else if (msgType == Constants.COMMENT) { CommentRepo commentRepo = BroadrApp.getCommentRepo(); Comment comment = commentRepo.getComment(uuid); if (comment != null) { jobManager.addJobInBackground( new SendCommentJob(comment.getId(), comment.getContent(), comment.getUuid())); } } } else { //sendNotification("Send error: " + extras.toString()); } } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), NOTIFICATION_ID); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { //parse the message and do db operations post the event //Post notification of received message. String receivedMessageType = extras.getString("t"); String messageId = null; MessageRepo messageRepo = BroadrApp.getMessageRepo(); CommentRepo commentRepo = BroadrApp.getCommentRepo(); Message message = null; Comment comment = null; if (null != extras.get("m_id")) { messageId = String.valueOf(extras.get("m_id")); } //check the message id prefix and find the comment or message if (messageId != null && messageId.startsWith(Constants.MESSAGE_PREFIX)) { messageId = messageId.substring(Constants.MESSAGE_PREFIX.length()); message = messageRepo.getMessage(messageId); } else if (messageId != null && messageId.startsWith(Constants.COMMENT_PREFIX)) { messageId = messageId.substring(Constants.COMMENT_PREFIX.length()); comment = commentRepo.getComment(messageId); } else if (messageId != null && messageId.startsWith(Constants.GCM_REGISTRATION)) { EventBus.getDefault().post(new SentRegistrationMessageEvent()); } else if (messageId != null && messageId.startsWith(Constants.LOCATION_PREFIX)) { EventBus.getDefault().post(new SentLocationEvent()); } if (extras.get("o") != null) { sendNotification(String.valueOf(extras.get("o")), 2); } if (message == null) { int type = 0; if (receivedMessageType != null) { switch (receivedMessageType.charAt(0)) { case 'r': type = 0; break; case 'l': type = 1; break; case 'm': type = 2; //received from gcm by others String content = String.valueOf(extras.get("c")); String geoHash = String.valueOf(extras.get("l")); String uuid = String.valueOf(extras.get("s_id")); message = messageRepo.getMessage(uuid); if (message == null) { message = new Message(content, new Date(), geoHash); message.setType(Constants.MESSAGE); message.setUpdatedAt(new Date()); message.setStatus(Constants.RECEIVED_GCM); message.setUuid(uuid); Board currentBoard = (Board) AppSingleton.getObj(Constants.CURRENT_BOARD_OBJ); if (currentBoard == null) { String board = BroadrApp.getSharedPreferences().getString(Constants.LAST_BOARD, null); if (board != null && board.length() >= 4) { currentBoard = BroadrApp.getBoardRepo().getBoard(board.substring(0, 4)); } } if (message.getHappenedAt().getTime() > new Date().getTime()) { message.setHappenedAt(new Date()); } message.setBoard(currentBoard); messageRepo.insertOrReplace(message); EventBus.getDefault().post(new SavedReceivedMessagesEvent()); EventBus.getDefault().post(new ReceivedGCMMessageEvent(message)); long when = Long.valueOf(BroadrApp.getSettingsPreferences() .getString(SettingsActivity.NOTIF_PERIOD, "1")).longValue(); if (when == 1) { checkNumberOfReceivedMessagesTillNowAndNotify(false); } } break; case 'c': type = 3; break; case 'a': type = 5; break; default: type = 0; break; } if (receivedMessageType.equals("lk")) { type = 4; } } } else { //this guy's message message.setUpdatedAt(new Date()); message.setStatus(Constants.DELIVERED); messageRepo.updateMessage(message); //message sent event EventBus.getDefault().post(new DeliveredRavenEvent(message)); mNotificationManager.cancel(StringUtilities.safeLongToInt(message.getId())); } if (comment != null) { comment.setHappenedAt(new Date()); comment.setUpdatedAt(new Date()); comment.setStatus(Constants.DELIVERED); commentRepo.updateComment(comment); //comment sent event EventBus.getDefault().post(new CommentDeliveredEvent(comment)); } } else { Log.d(Constants.APPTAG, messageType); //sendNotification(messageType); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.chen.mail.ui.AbstractActivityController.java
/** * Handle an intent to open the app. This method is called only when there is no saved state, * so we need to set state that wasn't set before. It is correct to change the viewmode here * since it has not been previously set. * * This method is called for a subset of the reasons mentioned in * {@link #onCreate(android.os.Bundle)}. Notably, this is called when launching the app from * notifications, widgets, and shortcuts. * @param intent intent passed to the activity. *///from w w w . j av a 2 s. com private void handleIntent(Intent intent) { LogUtils.d(LOG_TAG, "IN AAC.handleIntent. action=%s", intent.getAction()); if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { setAccount(Account.newinstance(intent.getStringExtra(Utils.EXTRA_ACCOUNT))); } if (mAccount == null) { return; } final boolean isConversationMode = intent.hasExtra(Utils.EXTRA_CONVERSATION); if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE, AnalyticsUtils.getAccountTypeForAccount(mAccount.getEmailAddress())); Analytics.getInstance().sendEvent("notification_click", isConversationMode ? "conversation" : "conversation_list", null, 0); } if (isConversationMode && mViewMode.getMode() == ViewMode.UNKNOWN) { mViewMode.enterConversationMode(); } else { mViewMode.enterConversationListMode(); } // Put the folder and conversation, and ask the loader to create this folder. final Bundle args = new Bundle(); final Uri folderUri; if (intent.hasExtra(Utils.EXTRA_FOLDER_URI)) { folderUri = (Uri) intent.getParcelableExtra(Utils.EXTRA_FOLDER_URI); } else if (intent.hasExtra(Utils.EXTRA_FOLDER)) { final Folder folder = Folder.fromString(intent.getStringExtra(Utils.EXTRA_FOLDER)); folderUri = folder.folderUri.fullUri; } else { final Bundle extras = intent.getExtras(); LogUtils.d(LOG_TAG, "Couldn't find a folder URI in the extras: %s", extras == null ? "null" : extras.toString()); folderUri = mAccount.settings.defaultInbox; } args.putParcelable(Utils.EXTRA_FOLDER_URI, folderUri); args.putParcelable(Utils.EXTRA_CONVERSATION, intent.getParcelableExtra(Utils.EXTRA_CONVERSATION)); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { mHaveSearchResults = false; // Save this search query for future suggestions. final String query = intent.getStringExtra(SearchManager.QUERY); final String authority = mContext.getString(R.string.suggestions_authority); final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(mContext, authority, SuggestionsProvider.MODE); suggestions.saveRecentQuery(query, null); setAccount((Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT)); fetchSearchFolder(intent); if (shouldEnterSearchConvMode()) { mViewMode.enterSearchResultsConversationMode(); } else { mViewMode.enterSearchResultsListMode(); } } else { LogUtils.e(LOG_TAG, "Missing account extra from search intent. Finishing"); mActivity.finish(); } } if (mAccount != null) { restartOptionalLoader(LOADER_ACCOUNT_UPDATE_CURSOR, mAccountCallbacks, Bundle.EMPTY); } }
From source file:com.android.mail.ui.AbstractActivityController.java
/** * Handle an intent to open the app. This method is called only when there is no saved state, * so we need to set state that wasn't set before. It is correct to change the viewmode here * since it has not been previously set. * * This method is called for a subset of the reasons mentioned in * {@link #onCreate(android.os.Bundle)}. Notably, this is called when launching the app from * notifications, widgets, and shortcuts. * @param intent intent passed to the activity. *///w ww. j av a 2s . co m private void handleIntent(Intent intent) { LogUtils.d(LOG_TAG, "IN AAC.handleIntent. action=%s", intent.getAction()); if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { setAccount(Account.newInstance(intent.getStringExtra(Utils.EXTRA_ACCOUNT))); } if (mAccount == null) { return; } final boolean isConversationMode = intent.hasExtra(Utils.EXTRA_CONVERSATION); if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().setEmail(mAccount.getEmailAddress(), mAccount.getType()); Analytics.getInstance().sendEvent("notification_click", isConversationMode ? "conversation" : "conversation_list", null, 0); } if (isConversationMode && mViewMode.getMode() == ViewMode.UNKNOWN) { mViewMode.enterConversationMode(); } else { mViewMode.enterConversationListMode(); } // Put the folder and conversation, and ask the loader to create this folder. final Bundle args = new Bundle(); final Uri folderUri; if (intent.hasExtra(Utils.EXTRA_FOLDER_URI)) { folderUri = intent.getParcelableExtra(Utils.EXTRA_FOLDER_URI); } else if (intent.hasExtra(Utils.EXTRA_FOLDER)) { final Folder folder = Folder.fromString(intent.getStringExtra(Utils.EXTRA_FOLDER)); folderUri = folder.folderUri.fullUri; } else { final Bundle extras = intent.getExtras(); LogUtils.d(LOG_TAG, "Couldn't find a folder URI in the extras: %s", extras == null ? "null" : extras.toString()); folderUri = mAccount.settings.defaultInbox; } // Check if we should load all conversations instead of using // the default behavior which loads an initial subset. mIgnoreInitialConversationLimit = intent.getBooleanExtra(Utils.EXTRA_IGNORE_INITIAL_CONVERSATION_LIMIT, false); args.putParcelable(Utils.EXTRA_FOLDER_URI, folderUri); args.putParcelable(Utils.EXTRA_CONVERSATION, intent.getParcelableExtra(Utils.EXTRA_CONVERSATION)); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { mHaveSearchResults = false; // Save this search query for future suggestions final String query = intent.getStringExtra(SearchManager.QUERY); mSearchViewController.saveRecentQuery(query); setAccount((Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT)); fetchSearchFolder(intent); if (shouldEnterSearchConvMode()) { mViewMode.enterSearchResultsConversationMode(); } else { mViewMode.enterSearchResultsListMode(); } } else { LogUtils.e(LOG_TAG, "Missing account extra from search intent. Finishing"); mActivity.finish(); } } if (mAccount != null) { restartOptionalLoader(LOADER_ACCOUNT_UPDATE_CURSOR, mAccountCallbacks, Bundle.EMPTY); } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
/** * Add a widget to the workspace.//from www .ja va 2 s . c o m * * @param data * The intent describing the appWidgetId. * @param cellInfo * The position on screen where to create the widget. */ private void completeAddAppWidget(Intent data, PersonaCellLayout.CellInfo cellInfo, final boolean insertAtFirst) { Bundle extras = data.getExtras(); final int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); if (LOGD) PersonaLog.d(LOG_TAG, "dumping extras content=" + extras.toString()); final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId); // Calculate the grid spans needed to fit this widget PersonaCellLayout layout = (PersonaCellLayout) mWorkspace.getChildAt(cellInfo.screen); final int[] spans = layout.rectToCell(appWidgetInfo.minWidth, appWidgetInfo.minHeight); final PersonaCellLayout.CellInfo cInfo = cellInfo; AlertDialog.Builder builder; AlertDialog alertDialog; final View dlg_layout = View.inflate(PersonaLauncher.this, R.layout.pr_widget_span_setup, null); final PersonaNumberPicker ncols = (PersonaNumberPicker) dlg_layout.findViewById(R.id.widget_columns_span); ncols.setRange(1, mWorkspace.currentDesktopColumns()); ncols.setCurrent(spans[0]); final PersonaNumberPicker nrows = (PersonaNumberPicker) dlg_layout.findViewById(R.id.widget_rows_span); nrows.setRange(1, mWorkspace.currentDesktopRows()); nrows.setCurrent(spans[1]); // 290661 changes spans[0] = 3; spans[1] = 2; realAddWidget(appWidgetInfo, cInfo, spans, appWidgetId, insertAtFirst); /* * builder = new AlertDialog.Builder(PersonaLauncher.this); * builder.setView(dlg_layout); alertDialog = builder.create(); * alertDialog * .setTitle(getResources().getString(R.string.widget_config_dialog_title * )); alertDialog.setMessage(getResources().getString(R.string. * widget_config_dialog_summary)); * alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, * getResources().getString(android.R.string.ok), new * DialogInterface.OnClickListener() { public void * onClick(DialogInterface dialog, int which) { * spans[0]=ncols.getCurrent(); spans[1]=nrows.getCurrent(); * realAddWidget(appWidgetInfo,cInfo,spans,appWidgetId,insertAtFirst); } * }); alertDialog.show(); */ }
From source file:com.tct.mail.ui.AbstractActivityController.java
/** * Handle an intent to open the app. This method is called only when there is no saved state, * so we need to set state that wasn't set before. It is correct to change the viewmode here * since it has not been previously set. * * This method is called for a subset of the reasons mentioned in * {@link #onCreate(android.os.Bundle)}. Notably, this is called when launching the app from * notifications, widgets, and shortcuts. * @param intent intent passed to the activity. *///from w w w. java2 s .c om private void handleIntent(Intent intent) { LogUtils.d(LOG_TAG, "IN AAC.handleIntent. action=%s", intent.getAction()); if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { setAccount(Account.newInstance(intent.getStringExtra(Utils.EXTRA_ACCOUNT))); } if (mAccount == null) { return; } final boolean isConversationMode = intent.hasExtra(Utils.EXTRA_CONVERSATION); if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE, AnalyticsUtils.getAccountTypeForAccount(mAccount.getEmailAddress())); Analytics.getInstance().sendEvent("notification_click", isConversationMode ? "conversation" : "conversation_list", null, 0); } if (isConversationMode && mViewMode.getMode() == ViewMode.UNKNOWN) { mViewMode.enterConversationMode(); } else { mViewMode.enterConversationListMode(); } // Put the folder and conversation, and ask the loader to create this folder. final Bundle args = new Bundle(); final Uri folderUri; if (intent.hasExtra(Utils.EXTRA_FOLDER_URI)) { folderUri = intent.getParcelableExtra(Utils.EXTRA_FOLDER_URI); } else if (intent.hasExtra(Utils.EXTRA_FOLDER)) { final Folder folder = Folder.fromString(intent.getStringExtra(Utils.EXTRA_FOLDER)); folderUri = folder.folderUri.fullUri; //TS: junwei-xu 2014-1-5 EMAIL BUGFIX_879468 ADD_S } else if (intent.getData() != null) { folderUri = intent.getData(); //TS: junwei-xu 2014-1-5 EMAIL BUGFIX_879468 ADD_E } else { final Bundle extras = intent.getExtras(); LogUtils.d(LOG_TAG, "Couldn't find a folder URI in the extras: %s", extras == null ? "null" : extras.toString()); folderUri = mAccount.settings.defaultInbox; } // Check if we should load all conversations instead of using // the default behavior which loads an initial subset. mIgnoreInitialConversationLimit = intent.getBooleanExtra(Utils.EXTRA_IGNORE_INITIAL_CONVERSATION_LIMIT, false); args.putParcelable(Utils.EXTRA_FOLDER_URI, folderUri); args.putParcelable(Utils.EXTRA_CONVERSATION, intent.getParcelableExtra(Utils.EXTRA_CONVERSATION)); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { mHaveSearchResults = false; //TS: zheng.zou 2015-03-18 EMAIL BUGFIX_744708 ADD_S mToastBar.hide(false, false); //TS: zheng.zou 2015-03-18 EMAIL BUGFIX_744708 ADD_E // Save this search query for future suggestions. final String query = intent.getStringExtra(SearchManager.QUERY); final String authority = mContext.getString(R.string.suggestions_authority); final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(mContext, authority, SuggestionsProvider.MODE); suggestions.saveRecentQuery(query, null); setAccount((Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT)); fetchSearchFolder(intent); if (shouldEnterSearchConvMode()) { mViewMode.enterSearchResultsConversationMode(); } else { mViewMode.enterSearchResultsListMode(); } /** TCT: init the list context for remote search, except folder. @{ */ // use a UNINITIALIZED folder temporarily. need update when finish search load. Folder folder = Folder.newUnsafeInstance(); mConvListContext = ConversationListContext.forSearchQuery(mAccount, folder, query); mConvListContext .setSearchField(mActivity.getIntent().getStringExtra(SearchParams.BUNDLE_QUERY_FIELD)); /** @} */ } else { /** TCT: The action is search but no extra account means it's a global search. @{ */ mGlobalSearch = true; LogUtils.logFeature(LogTag.SEARCH_TAG, "Handle ACTION_SEARCH , is mGlobalSearch [%s]", mGlobalSearch); // reload conbined inbox folder if needed. if (mAccount != null && (mFolder == null || !mFolder.isInitialized())) { Bundle args = new Bundle(); LogUtils.logFeature(LogTag.SEARCH_TAG, " GlobalSearch but without Folder, reload inbox again."); args.putParcelable(Utils.EXTRA_FOLDER_URI, mAccount.settings.defaultInbox); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } /** @} */ } } if (mAccount != null) { restartOptionalLoader(LOADER_ACCOUNT_UPDATE_CURSOR, mAccountCallbacks, Bundle.EMPTY); } }