List of usage examples for android.os Bundle getString
@Nullable
public String getString(@Nullable String key)
From source file:it.sineo.android.tileMapEditor.TileMap.java
public TileMap(Bundle b) { name = b.getString("name"); rows = b.getInt("rows"); columns = b.getInt("columns"); scale = b.getFloat("scale"); xOff = b.getFloat("xOff"); yOff = b.getFloat("yoff"); tilePaths = new String[rows][columns]; tileBitmaps = new Bitmap[rows][columns]; tileAngles = new byte[rows][columns]; tileMatrices = new Matrix[rows][columns]; for (int idxRow = 0; idxRow < rows; idxRow++) { for (int idxCol = 0; idxCol < columns; idxCol++) { if (b.containsKey("paths_" + idxRow + "_" + idxCol)) { tilePaths[idxRow][idxCol] = b.getString("paths_" + idxRow + "_" + idxCol); tileAngles[idxRow][idxCol] = b.getByte("angles_" + idxRow + "_" + idxCol); }/*from ww w . ja va 2 s . com*/ } } }
From source file:com.savvywits.wethepeople.RESTService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); ResultReceiver receiver = extras.getParcelable("receiver"); String data = extras.getString("zipcode"); String url = ZIP_CODE_BASE + data; Bundle bundle = new Bundle(); receiver.send(STATUS_RUNNING, Bundle.EMPTY); try {//from w w w . j av a 2s . com String json = EntityUtils.toString(new DefaultHttpClient().execute(new HttpGet(url)).getEntity()); if (!validateJSON(json)) { receiver.send(STATUS_ERROR, Bundle.EMPTY); } else { bundle.putString("rest_result", json); receiver.send(STATUS_FINISHED, bundle); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } }
From source file:co.uk.gauntface.mobile.devicelab.receiver.PushNotificationReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.v(C.TAG, "PushNotificationReceiver: Received Notification"); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //sendNotification("Send error: " + intent.getExtras().toString()); Log.e(C.TAG, "PushNotificationReceiver: MESSAGE_TYPE_SEND_ERROR"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.e(C.TAG, "PushNotificationReceiver: MESSAGE_TYPE_DELETED"); } else {//from ww w . j a v a 2 s. c om Bundle data = intent.getExtras(); if (data != null) { String dataString = data.getString("data"); Log.v(C.TAG, "PushNotificationReceiver: dataString = " + dataString); try { JSONObject dataObject = new JSONObject(dataString); String url = validateUrl(dataObject.optString("url")); String packageName = dataObject.optString("pkg"); if (url != null) { launchBrowserTask(context, url, packageName); } } catch (JSONException e) { Log.e(C.TAG, "PushNotificationReceiver: JSONException ", e); } } } setResultCode(Activity.RESULT_OK); }
From source file:com.example.jkgan.pmot.service.MyGcmListenerService.java
/** * Called when message is received./*from w ww .java 2 s . c o m*/ * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); String title = data.getString("title"); String promotion_id = data.getString("promotion_id"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ sendNotification(message, title, promotion_id); }
From source file:jp.co.conit.sss.sn.ex2.service.SendMessageIdIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (extras != null) { startActivity4Userdata(extras.getString("sn_userdata")); String snMessageId = extras.getString("mid"); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); String registrationId = preferences.getString("regist_id", ""); if (!StringUtil.isEmpty(registrationId)) { SNParam param = SNApiUtil.generateSNPraram(); param.setDeviceToken(registrationId); param.setMid(snMessageId);// w w w . ja v a2 s . com sendMidSamuraiNotificationServer(param); } } }
From source file:com.browsertophone.AppEngineClient.java
private String getAuthToken(Context context, Account account) { String authToken = null;/*ww w. j a v a 2 s . c om*/ AccountManager accountManager = AccountManager.get(context); try { AccountManagerFuture<Bundle> future = accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, false, null, null); Bundle bundle = future.getResult(); authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); // User will be asked for "App Engine" permission. if (authToken == null) { // No auth token - will need to ask permission from user. Intent intent = new Intent(SetupActivity.AUTH_PERMISSION_ACTION); intent.putExtra("AccountManagerBundle", bundle); context.sendBroadcast(intent); } } catch (OperationCanceledException e) { Log.w(TAG, e.getMessage()); } catch (AuthenticatorException e) { Log.w(TAG, e.getMessage()); } catch (IOException e) { Log.w(TAG, e.getMessage()); } return authToken; }
From source file:com.pusher.PusherModule.java
@Kroll.method(runOnUiThread = true) public void connect() { mHandler = new Handler() { public void handleMessage(Message msg) { super.handleMessage(msg); Bundle bundleData = msg.getData(); if (bundleData.getString("type").contentEquals("pusher")) { try { JSONObject message = new JSONObject(bundleData.getString("message")); Log.d("Pusher Message", message.toString()); if (message.getString("event").equals("connection_established")) { PusherModule.this.fireEvent("connected", null); }/*w ww . j av a 2s . c om*/ if (PusherModule.this.hasListeners(message.getString("event"))) { KrollDict event = new KrollDict(); event.put("name", message.getString("event")); JSONObject data = new JSONObject(message.getString("data")); event.put("data", KrollDict.fromJSON(data)); PusherModule.this.fireEvent(message.getString("event"), event); } } catch (Exception e) { e.printStackTrace(); } } if (bundleData.getString("type").contentEquals("pusher:disconnected")) { PusherModule.this.fireEvent("disconnected", null); } } }; mPusher = new Pusher(mReconnectAutomatically, mReconnectDelay); mPusher.addHandler(mHandler); mPusher.connect(mPusherKey); }
From source file:com.folio3.parse.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ParseAnalytics.trackAppOpenedInBackground(getIntent()); String filePath = getApplicationContext().getFilesDir().getPath().toString() + "/" + FILE; File file = new File(filePath); try {/*w w w . j ava2 s .c o m*/ if (!file.exists()) { System.out.println("Creating new file"); file.createNewFile(); } } catch (IOException ex) { ex.printStackTrace(); } /** When push message is clicked onCreate function of this activity is called */ Bundle extras = getIntent().getExtras(); if (extras != null && extras.getString(KEY_PUSH_DATA) != null) { JSONObject pushData = null; try { pushData = new JSONObject(extras.getString(KEY_PUSH_DATA)); } catch (JSONException e) { Log.e(TAG, "Unexpected JSONException when receiving push data: ", e); } String alert = null; if (pushData != null) { alert = pushData.optString("alert", null); } // Write log to the logfile if (alert != null) { writeLogToFile(getApplicationContext(), alert); FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment pushFragment = new PushFragment(); ft.replace(R.id.push_fragment, pushFragment); ft.commit(); } } }
From source file:com.lvlstudios.android.gtmessage.AppEngineClient.java
private String getAuthToken(Context context, Account account) throws PendingAuthException { String authToken = null;/* w w w . j a va2 s .c o m*/ AccountManager accountManager = AccountManager.get(context); try { AccountManagerFuture<Bundle> future = accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, false, null, null); Bundle bundle = future.getResult(); authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); if (authToken == null) { throw new PendingAuthException(bundle); } } catch (OperationCanceledException e) { Log.w(TAG, "AppEngineClient.getAuthToken " + e); } catch (AuthenticatorException e) { Log.w(TAG, "AppEngineClient.getAuthToken " + e); } catch (IOException e) { Log.w(TAG, "AppEngineClient.getAuthToken " + e); } return authToken; }
From source file:fr.julienvermet.bugdroid.service.ProductsIntentService.java
@Override protected void onHandleIntent(Intent intent) { Context context = getApplicationContext(); Bundle bundle = intent.getExtras(); String query = bundle.getString(QUERY); int instances_id = bundle.getInt(INSTANCES_ID); int accounts_id = bundle.getInt(ACCOUNTS_ID, -1); boolean forceReload = bundle.getBoolean(FORCE_RELOAD); ArrayList<Product> products = null; if (!forceReload) { String selection = Products.Columns.INSTANCES_ID.getName() + "=" + instances_id + " AND " + Products.Columns.ACCOUNTS_ID.getName() + "=" + accounts_id; String sortOrder = Products.Columns.NAME.getName(); Cursor cursor = context.getContentResolver().query(Products.CONTENT_URI, Products.PROJECTION, selection, null, sortOrder);/*from w ww . jav a 2 s.co m*/ if (cursor.getCount() > 0) { products = new ArrayList<Product>(); for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); Product product = Product.toProduct(cursor); products.add(product); } sendResult(intent, products); return; } cursor.close(); } String jsonString = NetworkUtils.readJson(query).result; products = parse(jsonString); sendResult(intent, products); // Delete old products for instance String selection = Products.Columns.INSTANCES_ID + "=" + instances_id + " AND " + Products.Columns.ACCOUNTS_ID.getName() + "=" + accounts_id; context.getContentResolver().delete(Products.CONTENT_URI, selection, null); context.getContentResolver().bulkInsert(Products.CONTENT_URI, Product.toContentValues(products, instances_id, accounts_id)); }