@Override public void onReceive(Context context, Intent intent) { LogHandler.configureLogger(); try { String log = "onReceive: Action: "; log += intent.getAction(); log += "( "; if (intent.getData() != null) { log += intent.getData().getScheme(); log += "://"; log += intent.getData().getHost(); } log += " ) "; Bundle extras = intent.getExtras(); log += "{ "; if (extras != null) { for (String extra : extras.keySet()) { log += extra + "[" + extras.get(extra) + "], "; } } log += " }"; Log.d(this, log); } catch (Exception e) { Log.e(e); } try { if (ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT .ALARM_TRIGGERED .getIntentAction() .equals(intent.getAction())) { Log.d("IntentReceiver", "Alarm triggered!"); ActionHandler.execute( context, ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT.ALARM_TRIGGERED); } else if (ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT .ALARM_SNOOZED .getIntentAction() .equals(intent.getAction())) { Log.d("IntentReceiver", "Alarm snoozed..."); ActionHandler.execute( context, ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT.ALARM_SNOOZED); } else if (ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT .ALARM_DISMISSED .getIntentAction() .equals(intent.getAction())) { Log.d("IntentReceiver", "Alarm dismissed..."); ActionHandler.execute( context, ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT.ALARM_DISMISSED); } else { Log.d("IntentReceiver", "Received unknown intent: " + intent.getAction()); } } catch (Exception e) { Log.e(e); } }
public void onCreate(Activity activity, Bundle savedInstanceState) { PackageManager manager = activity.getBaseContext().getPackageManager(); String[] keys = {"tapjoyAppID", "tapjoySecretKey"}; try { Bundle meta = manager.getApplicationInfo( activity.getApplicationContext().getPackageName(), PackageManager.GET_META_DATA) .metaData; for (String k : keys) { if (meta.containsKey(k)) { manifestKeyMap.put(k, meta.get(k).toString()); } } } catch (Exception e) { logger.log("Exception while loading manifest keys:", e); } String tapJoyAppID = manifestKeyMap.get("tapjoyAppID"); String tapJoySecretKey = manifestKeyMap.get("tapjoySecretKey"); logger.log("{tapjoy} Installing for appID:", tapJoyAppID); // Enables logging to the console. // TapjoyLog.enableLogging(true); // Connect with the Tapjoy server. TapjoyConnect.requestTapjoyConnect(_ctx, tapJoyAppID, tapJoySecretKey); }
@Override @SuppressWarnings("unchecked") public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); LogUtils.logd(TAG, "[onActivityCreated]"); mSession = JRSession.getInstance(); if (savedInstanceState != null) { mManagedDialogs = (HashMap) savedInstanceState.get(KEY_MANAGED_DIALOGS); Parcelable[] p = savedInstanceState.getParcelableArray(KEY_MANAGED_DIALOG_OPTIONS); if (mManagedDialogs != null && p != null) { for (Parcelable p_ : p) { Bundle b = (Bundle) p_; mManagedDialogs.get(b.getInt(KEY_DIALOG_ID)).mOptions = b; } } else { mManagedDialogs = new HashMap<Integer, ManagedDialog>(); } } for (ManagedDialog d : mManagedDialogs.values()) { d.mDialog = onCreateDialog(d.mId, d.mOptions); if (d.mShowing) d.mDialog.show(); } }
public void testAssistContentAndAssistData() throws Exception { mTestActivity.startTest(TEST_CASE_TYPE); waitForAssistantToBeReady(mReadyLatch); mTestActivity.start3pApp(TEST_CASE_TYPE); waitForOnResume(); startSession(); waitForContext(); verifyAssistDataNullness(false, false, false, false); Log.i(TAG, "assist bundle is: " + Utils.toBundleString(mAssistBundle)); // tests that the assist content's structured data is the expected assertEquals( "AssistContent structured data did not match data in onProvideAssistContent", Utils.getStructuredJSON(), mAssistContent.getStructuredData()); // tests the assist data. EXTRA_ASSIST_CONTEXT is what's expected. Bundle extraExpectedBundle = Utils.getExtraAssistBundle(); Bundle extraAssistBundle = mAssistBundle.getBundle(Intent.EXTRA_ASSIST_CONTEXT); for (String key : extraExpectedBundle.keySet()) { assertTrue( "Assist bundle does not contain expected extra context key: " + key, extraAssistBundle.containsKey(key)); assertEquals( "Extra assist context bundle values do not match for key: " + key, extraExpectedBundle.get(key), extraAssistBundle.get(key)); } }
/** * 解析Intent获取数据源。 * * @param intent */ private void parseIntent(Intent intent) { Bundle bundle = intent.getExtras(); if (bundle == null) { valid = false; return; } String path = bundle.getString(IntentData.PATH); if (path != null) { curStatus = STATUS_PREVIEW; filePath = path; File file = FileUtil.newFile(path); fileName = file.getName(); totalSizeStr = FileUtil.makeUpSizeShow(file.length()); return; } Object file = bundle.get(IntentData.GROUP_ZONE_FILE); if (file instanceof GroupFile) { curStatus = STATUS_GROUP_ZONE; groupFile = (GroupFile) file; fileName = groupFile.getFileName(); totalSizeStr = FileUtil.makeUpSizeShow(groupFile.getFileSize()); /*message = InstantMessageDao.getImById(groupFile.getInstantMessageId()); if (message != null) { resource = message.getMediaRes(); if (resource == null) { valid = false; return; } }*/ return; } Object tag = bundle.get(IntentData.MEDIA_RESOURCE); Object tag1 = bundle.get(IntentData.IM); if (tag instanceof MediaResource && tag1 instanceof InstantMessage) { curStatus = STATUS_UM; message = (InstantMessage) tag1; resource = (MediaResource) tag; fileName = resource.getName(); totalSizeStr = FileUtil.makeUpSizeShow(resource.getSize()); if (ContactLogic.getIns().getAbility().isSupportGroupZone()) { int id = new GroupZoneFileRelationDao().query((int) message.getId(), false); groupFile = new GroupZoneFileDao().query(id); } return; } valid = false; }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); System.out.println("\nonActivityResult"); System.out.println("requestCode: " + requestCode); System.out.println("resultCode: " + resultCode); System.out.println("REQUEST_TAKE_PHOTO: " + REQUEST_TAKE_PHOTO); System.out.println("REQUEST_IMAGE_CAPTURE: " + REQUEST_IMAGE_CAPTURE); System.out.println("RESULT_OK: " + RESULT_OK); // if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) { if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { if (data != null) { System.out.println("\nRecuperando data\n"); Bundle extras = data.getExtras(); System.out.println("\nMediaStore.EXTRA_OUTPUT\n"); // Bitmap imageBitmap = (Bitmap) extras.get("data"); System.out.println(extras.get(MediaStore.EXTRA_OUTPUT).getClass().getName()); Bitmap imageBitmap = (Bitmap) extras.get(MediaStore.EXTRA_OUTPUT); imgFoto.setImageBitmap(imageBitmap); } else { System.out.println("\ndata is null\n"); } } else { System.out.println("\nrequestCode != REQUEST_IMAGE_CAPTURE or resultCode != RESULT_OK\n"); } }
/** * This is a convenience method to test whether or not two bundles' contents are equal. This * method only works if the contents of each bundle are primitive data types or strings. Otherwise * this method may wrongly report they they are not equal. * * @param bundle1 * @param bundle2 * @return */ public static boolean areEqual(Bundle bundle1, Bundle bundle2) { // Null for none or both, or the same if (bundle1 == null) { return bundle2 == null; } else if (bundle2 == null) { return false; } else if (bundle1 == bundle2) { return true; } // Same key set Set<String> keySet = bundle1.keySet(); if (!keySet.equals(bundle2.keySet())) { return false; } // Same values in key set for (String key : keySet) { Object value1 = bundle1.get(key); Object value2 = bundle2.get(key); if (!(value1 == null ? value2 == null : value1.equals(value2))) { return false; } } return true; }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (intent.getAction() == "android.intent.action.SEARCH") { showSearch(false); // Suchfeld schliessen // Suchbegriff speichern in der Vorschlagsliste Bundle extras = intent.getExtras(); String userQuery = String.valueOf(extras.get(SearchManager.USER_QUERY)); String query = String.valueOf(extras.get(SearchManager.QUERY)); suggestions.saveRecentQuery(query, "in Kontakten"); // Toast.makeText(this, "query: " + query + " user_query: " + userQuery, // Toast.LENGTH_SHORT).show(); // TEST Meldung Bundle args = new Bundle(); // Uebergabe-Parameter für Fragment erstellen args.putString("search", query); getSupportActionBar().setSubtitle("Suche '" + query + "'"); showFragment("list", args); // Fragment OrdersList anzeigen } }
public ActiveRecordPartial where(Bundle data) { Set<String> keys = data.keySet(); for (String key : keys) { if (data.get(key) == null) continue; String whereSQL = ""; whereSQL = "'" + key + "' = " + data.get(key).toString(); _whereList.add(whereSQL); } return this; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); locationDB = new LocalDB(this); setContentView(R.layout.activity_location_edit); // initial all component initialComponent(); // get intent // if intent = res_add, open add function // if intent = res_edit,open edit function mBundle = getIntent().getExtras(); String neededFunction = (String) mBundle.get("from"); // add function if (neededFunction.compareTo("location_add") == 0) { // do not show remove in add function remove.setVisibility(View.INVISIBLE); edit.setVisibility(View.INVISIBLE); viewChildren.setVisibility(View.INVISIBLE); // save button for add function this.setSaveListenerForAdd(); } else if (neededFunction.compareTo("location_view") == 0) { // edit function setTextFromIntent(); id = (String) mBundle.get("itemID"); // viewIntent.putExtra("itemID", itemID); // all data can not be changed save.setVisibility(View.INVISIBLE); remove.setVisibility(View.INVISIBLE); setUnEditable(); // click edit, set all fields editable, and set save button visible this.setEditListenerForView(); // save button this.setSaveListenerForView(); // remove button this.setRemoveListenerForVie(); // viewChildren button this.setViewChildrenListenerForView(); } else { // if the value is neither res_view or res_add, output bug log Log.e("error", "Intent from researcherList is neither res_view or res_add"); } }
public int update_all(Bundle data) { Set<String> keys = data.keySet(); ContentValues cv = new ContentValues(); for (String key : keys) { if (data.get(key) == null) continue; Tools.putObjectToContentValues(cv, key, data.get(key)); } int count = _db.update(_tableName, cv, Tools.join(_whereList, " AND "), null); this.release(); return count; }
public static boolean bundleEquals( final Bundle bundle1, final Bundle bundle2, final String... ignoredKeys) { if (bundle1 == null || bundle2 == null) return bundle1 == bundle2; final Iterator<String> keys = bundle1.keySet().iterator(); while (keys.hasNext()) { final String key = keys.next(); if (!ArrayUtils.contains(ignoredKeys, key) && !objectEquals(bundle1.get(key), bundle2.get(key))) return false; } return true; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); // Getting status int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext()); // Showing status if (status == ConnectionResult.SUCCESS) { } else { int requestCode = 10; Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode); dialog.show(); return; } // requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); if (savedInstanceState != null) { allTapItem = (ArrayList<OSMNode>) savedInstanceState.get("allTapItem"); allToiletItem = (ArrayList<OSMNode>) savedInstanceState.get("allToiletItem"); allFoodItem = (ArrayList<OSMNode>) savedInstanceState.get("allFoodItem"); } // TODO Semi-Transparent Action Bar // requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); // getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_bg_black)); setContentView(R.layout.activity_main); configureActionBar(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); mMapFragment = getSupportFragmentManager().findFragmentByTag("map"); if (mMapFragment == null) { // If not, instantiate and add it to the activity mMapFragment = new ViewMapFragment_(); ft.add(R.id.container, mMapFragment, "map").commit(); } else { // If it exists, simply attach it in order to show it ft.show(mMapFragment).commit(); } TapForTap.initialize(this, "ef3209aec5ac8e0eb9682b8890b20a78"); adview = (AdView) findViewById(R.id.adView); adview.setAdListener(this); ImageButton imgbtn = (ImageButton) findViewById(R.id.closeadbtn); imgbtn.setVisibility(View.GONE); // Initiate a generic request to load it with an ad AdRequest request = new AdRequest(); adview.loadAd(request); // Search markers searchMarkers = new ArrayList<Marker>(); }
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); String ssidStr = (String) icicle.get("ssid"); if (ssidStr != null) { mSsid = ssidStr; } String serverStr = (String) icicle.get("server"); if (serverStr != null) { mTestServer = serverStr; } }
public ActiveRecordPartialInstance create(Bundle data) { Set<String> keys = data.keySet(); ContentValues cv = new ContentValues(); Bundle b = new Bundle(); for (String key : keys) { if (data.get(key) == null) continue; Tools.putObjectToContentValues(cv, key, data.get(key)); b.putString(key, data.get(key).toString()); } _db.insert(_tableName, null, cv); this.release(); return new ActiveRecordPartialInstance(this, b); }
private void debugIntent(Intent intent, String tag) { Log.v(tag, "action: " + intent.getAction()); Log.v(tag, "component: " + intent.getComponent()); Bundle extras = intent.getExtras(); if (extras != null) { for (String key : extras.keySet()) { Log.v(tag, "key [" + key + "]: " + extras.get(key)); Log.v(tag, extras.get(key).getClass().toString()); } } else { Log.v(tag, "no extras"); } }
public void testValidateAccount() throws Exception { setupAccountMailboxAndMessages(0); HostAuth auth = new HostAuth(); auth.mAddress = mAccount.mEmailAddress; auth.mProtocol = "eas"; auth.mLogin = mAccount.mDisplayName; auth.mPassword = "******"; auth.mPort = 80; EasSyncService eas = getTestService(mAccount, mMailbox); Bundle bundle = eas.validateAccount(auth, mProviderContext); assertEquals("14.1", bundle.get(EmailServiceProxy.VALIDATE_BUNDLE_PROTOCOL_VERSION)); assertEquals( MessagingException.NO_ERROR, bundle.get(EmailServiceProxy.VALIDATE_BUNDLE_RESULT_CODE)); }
public void restoreInstance(@Observes OnMapRestoreInstanceEvent event) { Bundle savedInstance = event.getSavedInstance(); map = event.getMap(); trackingService = (Intent) savedInstance.get("tracking_manager_service"); LinkedList list = (LinkedList) savedInstance.get("tracking_manager_waypoint"); polylineManager = (PolylineManager) list.getFirst(); eventManager.fire(new RedrawWaypointsEvent(context, map)); if (trackingService != null) { waypointBroadcastReceiver = new TrackingServiceWaypointBroadcastReceiver(); context.registerReceiver( waypointBroadcastReceiver, new IntentFilter(TrackingService.WAYPOINT_BROADCAST_RECEIVER)); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); MessageReference messageReference; if (savedInstanceState != null) { mPgpData = (PgpData) savedInstanceState.get(STATE_PGP_DATA); messageReference = (MessageReference) savedInstanceState.get(STATE_MESSAGE_REFERENCE); } else { Bundle args = getArguments(); messageReference = (MessageReference) args.getParcelable(ARG_REFERENCE); } displayMessage(messageReference, (mPgpData == null)); }
@Override protected void onCreate(Bundle savedInstanceState) { opzioni = SoulissApp.getOpzioni(); db = new SoulissDBTagHelper(this); if (opzioni.isLightThemeSelected()) setTheme(R.style.LightThemeSelector); else setTheme(R.style.DarkThemeSelector); super.onCreate(savedInstanceState); setContentView(R.layout.main_tag_detail); Bundle extras = getIntent().getExtras(); if (extras != null && extras.get("TAG") != null) tagId = (long) extras.get("TAG"); try { collected = db.getTag((int) tagId); } catch (SQLDataException sql) { Log.i(Constants.TAG, "TAGID NOT FOUND: " + tagId); } if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); fragment = new TagDetailFragment(); transaction.replace(R.id.detailPane, fragment); transaction.commit(); } /* try { setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { Log.i(Constants.TAG, "EnterSharedElement.onMapSharedElements:" + sharedElements.size()); //manual override perche il fragment ancora non c'e //sharedElements.put("photo_hero", fragment.getView().findViewById(R.id.photo)); // sharedElements.put("shadow_hero", fragment.getView().findViewById(R.id.infoAlpha)); // sharedElements.put("tag_icon", fragment.getView().findViewById(R.id.imageTagIcon)); super.onMapSharedElements(names, sharedElements); } @Override public void onRejectSharedElements(List<View> rejectedSharedElements) { Log.i(Constants.TAG, "EnterSharedElement.onMapSharedElements:" + rejectedSharedElements.size()); super.onRejectSharedElements(rejectedSharedElements); } }); } catch (Exception uie) { Log.e(Constants.TAG, "UIE:" + uie.getMessage()); }*/ }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_activity_place_details); /** get details of the place which send in previous activity * */ Intent receive_i = getIntent(); Bundle my_bundle_received = receive_i.getExtras(); sPlace = (SeachPlace) my_bundle_received.get("searchPlace"); /** Initialize the GUI textviews* */ System.out.println(sPlace.getName() + " name"); TextView name = (TextView) findViewById(R.id.place_name); TextView description = (TextView) findViewById(R.id.descrp); TextView telephone = (TextView) findViewById(R.id.tele); TextView link = (TextView) findViewById(R.id.webLink); TextView address = (TextView) findViewById(R.id.addre); ImageView image = (ImageView) findViewById(R.id.city_image); /** set data to the GUI* */ name.setText(sPlace.getName()); description.setText(sPlace.getDescription()); telephone.setText(sPlace.getPhone_no()); link.setText(sPlace.getWebLink()); address.setText(sPlace.getAddress()); System.out.println(sPlace.getDescription() + " description in place de"); }
/** * The IntentService calls this method from the default worker thread with the intent that started * the service. When this method returns, IntentService stops the service, as appropriate. */ @Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null) { Log.e(Constants.TAG, "Extras bundle is null!"); return; } if (intent.getAction() == null) { Log.e(Constants.TAG, "Intent must contain an action!"); return; } if (extras.containsKey(EXTRA_MESSENGER)) { mMessenger = (Messenger) extras.get(EXTRA_MESSENGER); } String action = intent.getAction(); setProgressCircleWithHandler(true); // execute action if (ACTION_CHANGE_COLOR.equals(action)) { // update calendar color if enabled if (new AccountHelper(this).isAccountActivated()) { CalendarSyncAdapterService.updateCalendarColor(this); } } else if (ACTION_MANUAL_COMPLETE_SYNC.equals(action)) { // perform blocking sync CalendarSyncAdapterService.performSync(this); } setProgressCircleWithHandler(false); }
// Result from choose image from gallery and take photo @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_IMAGE_CAPTURE: if (resultCode == Activity.RESULT_OK && data != null) { Log.v("prototypev1", "he entrat a capturar fto"); Bundle extras = data.getExtras(); Bitmap photo = (Bitmap) extras.get("data"); newProfilePicture = Bitmap.createScaledBitmap(photo, 80, 80, true); new SetProfilePictureTask().execute(); } break; case REQUEST_PICK_IMAGE: Log.v("prototypev1", "he entrat a triar foto"); if (resultCode == Activity.RESULT_OK && data != null) { Bitmap yourSelectedImage = searchPhotoSelect(data); newProfilePicture = Bitmap.createScaledBitmap(yourSelectedImage, 80, 80, true); // upload to parse new SetProfilePictureTask().execute(); } break; default: break; } profilePicture.setImageBitmap(newProfilePicture); }
@Override public void onReceive(Context context, Intent intent) { LocatorInjector.inject(this); // intent.getAction() == Activity.RESULT_OK Log.d(LocatorApplication.TAG, "onReceive() sms"); // Retrieves a map of extended data from the intent. final Bundle bundle = intent.getExtras(); try { if (bundle != null) { final Object[] pdusObj = (Object[]) bundle.get("pdus"); for (int i = 0; i < pdusObj.length; i++) { SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]); if (currentMessage != null) { SmsParsedRequest request = SmsParsedRequest.fromSms(currentMessage); if (request.isOurMessage()) { orderExecutor.createOrderFromIncomeSms(currentMessage); } } } } } catch (Exception e) { Log.e("SmsReceiver", "Exception smsReceiver" + e); } }
// create the Activity @Override public void onReceive(Context context, Intent intent) { // ---get the SMS message passed in--- Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; String str = ""; if (bundle != null) { // ---retrieve the SMS message received--- Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; for (int i = 0; i < msgs.length; i++) { msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); str += "SMS from " + msgs[i].getOriginatingAddress(); str += ":"; str += msgs[i].getMessageBody().toString(); str += "\n"; System.out.println(str); } Toast tost = Toast.makeText(context, str, Toast.LENGTH_LONG); tost.show(); Intent broadcastIntent = new Intent(); broadcastIntent.setAction("SMS_RECEIVED_ACTION"); broadcastIntent.putExtra("sms", str); context.sendBroadcast(broadcastIntent); } }
public static void printResultIntent(Context ctx, Intent intent) { String key; try { if (LibConf.ISRELEASE) return; if (ctx == null) return; if (intent == null) return; Log.d(LibConf.LOGTAG, "\r\n[ ACTIVITY RESULT ]"); if (intent.getComponent() != null) { String nm = intent.getComponent().toString(); Log.d(LibConf.LOGTAG, "ACTIVITY=[" + nm + "]"); } Bundle bundle = intent.getExtras(); if (bundle == null) return; for (Iterator<String> iter = intent.getExtras().keySet().iterator(); iter.hasNext(); ) { key = iter.next(); Log.d(LibConf.LOGTAG, key + "=[" + bundle.get(key).toString() + "]"); } } catch (Exception e) { Log.d(LibConf.LOGTAG, "[ printResultIntent error ]"); } }
/** * The IntentService calls this method from the default worker thread with the intent that started * the service. When this method returns, IntentService stops the service, as appropriate. */ @Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null) { Log.e(Constants.TAG, "Extras bundle is null!"); return; } if (!(extras.containsKey(EXTRA_ACTION))) { Log.e(Constants.TAG, "Extra bundle must contain an action!"); return; } if (extras.containsKey(EXTRA_MESSENGER)) { mMessenger = (Messenger) extras.get(EXTRA_MESSENGER); } Bundle data = extras.getBundle(EXTRA_DATA); int action = extras.getInt(EXTRA_ACTION); setProgressCircleWithHandler(true); // execute action from extra bundle switch (action) { case ACTION_CHANGE_COLOR: int newColor = data.getInt(CHANGE_COLOR_NEW_COLOR); // only if enabled if (new AccountHelper(this).isAccountActivated()) { // update calendar color CalendarSyncAdapterService.updateCalendarColor(this, newColor); } break; case ACTION_CHANGE_REMINDER: int newMinutes = data.getInt(CHANGE_REMINDER_NEW_MINUTES); int reminderNo = data.getInt(CHANGE_REMINDER_NO); // only if enabled if (new AccountHelper(this).isAccountActivated()) { // Update all reminders to new minutes CalendarSyncAdapterService.updateAllReminders(this, reminderNo, newMinutes); } break; case ACTION_MANUAL_SYNC: // Force synchronous sync CalendarSyncAdapterService.performSync(this); break; default: break; } setProgressCircleWithHandler(false); }
@Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Log.d("something happened", "great!"); if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) { Bundle bundle = intent.getExtras(); // ---get the SMS message passed in--- SmsMessage[] msgs = null; String msg_from; if (bundle != null) { // ---retrieve the SMS message received--- try { Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; for (int i = 0; i < msgs.length; i++) { msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); msg_from = msgs[i].getOriginatingAddress(); String msgBody = msgs[i].getMessageBody(); this.smsRPG.getMessage(msg_from, msgBody); } } catch (Exception e) { Log.d("Exception caught", e.getMessage()); } } } }
// Try to figure out if the value is another JSON object or JSON Array private void parseJsonProperty(String key, JSONObject json, Bundle extras, JSONObject jsondata) throws JSONException { if (extras.get(key) instanceof String) { String strValue = extras.getString(key); if (strValue.startsWith(JSON_START_PREFIX)) { try { JSONObject jsonObj = new JSONObject(strValue); jsondata.put(key, jsonObj); } catch (Exception e) { jsondata.put(key, strValue); } } else if (strValue.startsWith(JSON_ARRAY_START_PREFIX)) { try { JSONArray jsonArray = new JSONArray(strValue); jsondata.put(key, jsonArray); } catch (Exception e) { jsondata.put(key, strValue); } } else { if (!json.has(key)) { jsondata.put(key, strValue); } } } }
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) { Bundle bundle = intent.getExtras(); // ---get the SMS message passed in--- SmsMessage[] msgs = null; if (bundle != null) { // ---retrieve the SMS message received--- try { Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; if (msgs != null && msgs.length > 0) { ContentObject co = mContentManager.addSMSObject(msgs.length); // Add content using message count if (co != null) { mActivityHandler .obtainMessage(Constants.MESSAGE_SMS_RECEIVED, (Object) co) .sendToTarget(); // send to device sendContentsToDevice(co); } } // Use new message count only // for(int i=0; i<msgs.length; i++){ // msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]); // String msg_from = msgs[i].getOriginatingAddress(); // String msgBody = msgs[i].getMessageBody(); // } } catch (Exception e) { Logs.d(TAG, e.getMessage()); } } } } // End of onReceive()