List of usage examples for android.os Bundle isEmpty
public boolean isEmpty()
From source file:org.site_monitor.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dbHelper = DBHelper.getHelper(this); listView = this.findViewById(R.id.listView); connectivityAlertView = this.findViewById(R.id.connectivityAlert); chronometer = this.findViewById(R.id.chronometer); timerBannerView = this.findViewById(R.id.timerBanner); FragmentManager fragmentManager = getSupportFragmentManager(); taskFragment = (TaskFragment) fragmentManager.findFragmentByTag(TAG_TASK_FRAGMENT); if (taskFragment == null) { taskFragment = new TaskFragment(); fragmentManager.beginTransaction().add(taskFragment, TAG_TASK_FRAGMENT).commit(); }//from w w w. ja va2 s. c o m if (savedInstanceState == null || savedInstanceState.isEmpty()) { siteSettingsList = new ArrayList<>(); loadDataFromDb = true; } else { siteSettingsList = savedInstanceState.getParcelableArrayList(PARCEL_SITE_LIST); } siteSettingsAdapter = new SiteSettingsAdapter(context, this, siteSettingsList); listView.setAdapter(siteSettingsAdapter); if (networkBroadcastReceiver == null) { networkBroadcastReceiver = new NetworkBroadcastReceiver(this); } if (alarmBroadcastReceiver == null) { alarmBroadcastReceiver = new AlarmBroadcastReceiver(this); } // start alarm on 1st install or if not started on system boot alarmUtil.startAlarmIfNeeded(this); }
From source file:com.github.michalbednarski.intentslab.editor.IntentEditorActivity.java
public void runIntent() { updateIntent();/*from w w w .j a v a 2 s . c o m*/ IRemoteInterface remoteInterface = RunAsManager.getSelectedRemoteInterface(); Intent intent = mEditedIntent; IntentTracker intentTracker = getIntentTracker(); if (intentTracker != null) { intent = intentTracker.tagIntent(intent); } try { switch (getComponentType()) { case IntentEditorConstants.ACTIVITY: switch (getMethodId()) { case IntentEditorConstants.ACTIVITY_METHOD_STARTACTIVITY: if (remoteInterface != null) { startActivityRemote(remoteInterface, false); } else { startActivity(intent); } break; case IntentEditorConstants.ACTIVITY_METHOD_STARTACTIVITYFORRESULT: if (remoteInterface != null) { startActivityRemote(remoteInterface, true); } else { startActivityForResult(intent, REQUEST_CODE_TEST_STARTACTIVITYFORRESULT); } break; } break; case IntentEditorConstants.BROADCAST: switch (getMethodId()) { case IntentEditorConstants.BROADCAST_METHOD_SENDBROADCAST: sendBroadcast(intent); break; case IntentEditorConstants.BROADCAST_METHOD_SENDORDEREDBROADCAST: { sendOrderedBroadcast(intent, // intent null, // permission new BroadcastReceiver() { // resultReceiver @Override public void onReceive(Context context, Intent intent) { Bundle resultExtras = getResultExtras(false); new AlertDialog.Builder(IntentEditorActivity.this).setMessage(getString( R.string.received_broadcast_result) + "\ngetResultCode() = " + getResultCode() + "\ngetResultData() = " + getResultData() + "\ngetResultExtras() = " + (resultExtras == null ? "null" : resultExtras.isEmpty() ? "[Empty Bundle]" : "[Bundle]") ).setPositiveButton("OK", null).show(); } }, null, // scheduler 0, // initialCode null, // initialData null // initialExtras ); } break; case IntentEditorConstants.BROADCAST_METHOD_SENDSTICKYBROADCAST: sendStickyBroadcast(intent); break; } break; case IntentEditorConstants.SERVICE: switch (getMethodId()) { case IntentEditorConstants.SERVICE_METHOD_STARTSERVICE: startService(intent); break; default: { if (!SandboxManager.isSandboxInstalled(this)) { SandboxManager.requestSandboxInstall(this); } else { BindServiceManager.prepareBinderAndShowUI(this, new BindServiceDescriptor(new Intent(intent))); } } } break; case IntentEditorConstants.RESULT: setResult(0, new Intent().putExtra(EXTRA_FORWARD_RESULT_CODE, mMethodId) .putExtra(EXTRA_FORWARD_RESULT_INTENT, intent)); finish(); break; } } catch (Throwable exception) { Utils.toastException(this, exception); } }
From source file:com.rothconsulting.android.billing.util.IabHelper.java
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;/* w w w . j av a 2 s.co m*/ do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); Utils.log(mDebugTag, "++ --- ownedItems from Service = " + ownedItems); Utils.log(mDebugTag, "++ --- ownedItems itemType = " + itemType); Utils.log(mDebugTag, "++ --- ownedItems keySet = " + ownedItems.keySet()); Utils.log(mDebugTag, "++ --- ownedItems isEmpty = " + ownedItems.isEmpty()); Utils.log(mDebugTag, "++ --- ownedItems INAPP_PURCHASE_ITEM_LIST = " + ownedItems.get("INAPP_PURCHASE_ITEM_LIST")); Utils.log(mDebugTag, "++ --- ownedItems INAPP_PURCHASE_DATA_LIST = " + ownedItems.get("INAPP_PURCHASE_DATA_LIST")); Utils.log(mDebugTag, "++ --- ownedItems INAPP_DATA_SIGNATURE_LIST = " + ownedItems.get("INAPP_DATA_SIGNATURE_LIST")); Utils.log(mDebugTag, "++ --- ownedItems RESPONSE_CODE = " + ownedItems.get("RESPONSE_CODE")); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:com.sentaroh.android.Utilities.Dialog.FileSelectDialogFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mDebugEnable) Log.v(APPLICATION_TAG, "onSaveInstanceState"); if (outState.isEmpty()) { outState.putBoolean("WORKAROUND_FOR_BUG_19917_KEY", true); }//from w w w. j a v a 2s .c o m saveViewContents(); }
From source file:com.wareninja.opensource.common.wsrequest.WebServiceNew.java
public String webPost(String methodName, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os;//from w ww . j av a 2 s . c o m ret = null; String postUrl = webServiceUrl + methodName; if (LOGGING.DEBUG) { Log.d(TAG, "POST URL: " + postUrl); } HttpURLConnection conn = (HttpURLConnection) new URL(postUrl).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " WareNinjaAndroidSDK"); HttpParams httpParams = httpClient.getParams(); HttpProtocolParams.setUseExpectContinue(httpParams, false); Bundle dataparams = new Bundle(); for (String key : params.keySet()) { byte[] byteArr = null; try { byteArr = (byte[]) params.get(key); } catch (Exception ex1) { } if (byteArr != null) dataparams.putByteArray(key, byteArr); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); appendRequestHeaders(conn, headers); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((WareNinjaUtils.encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); String response = ""; try { response = WareNinjaUtils.read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = WareNinjaUtils.read(conn.getErrorStream()); } if (LOGGING.DEBUG) Log.d(TAG, "POST response: " + response); return response; }
From source file:com.ezeeideas.wordjam.BaseGameActivity.java
/** * Restore the instance of the game from the saved Bundle. This is usually * when the device screen was rotated while in the middle of the game. * //from w w w . j a v a2s . co m * Note: The game may or may not have been stored in the DB. * * @param savedInstanceState The bundle to restore state from */ private void restoreSavedInstance(Bundle savedInstanceState) { if (savedInstanceState != null && !savedInstanceState.isEmpty()) { mIsPlay = savedInstanceState.getBoolean(Constants.KEY_IS_PLAY); mPlayType = savedInstanceState.getInt(Constants.KEY_PLAY_TYPE); mGameNumber = savedInstanceState.getInt(Constants.KEY_GAME_NUM); mIsNewGame = savedInstanceState.getBoolean(Constants.KEY_IS_NEW_GAME); if (mIsPlay) { mLevel = savedInstanceState.getInt(Constants.KEY_LEVEL); mNumGamesInLevel = savedInstanceState.getInt(Constants.KEY_LEVEL_NUM_GAMES); mLevelPoints = savedInstanceState.getInt(Constants.KEY_LEVEL_POINTS); mLevelState = savedInstanceState.getInt(Constants.KEY_LEVEL_STATE); mLevelGamesRemaining = savedInstanceState.getInt(Constants.KEY_LEVEL_GAMES_REMAINING); mLevelHintsRemaining = savedInstanceState.getInt(Constants.KEY_LEVEL_HINTS_REMAINING); mLevelHintsEarned = savedInstanceState.getInt(Constants.KEY_LEVEL_HINTS_EARNED); } else { mPracticeType = savedInstanceState.getInt(Constants.KEY_PRACTICE_TYPE); mPracticeGamesCompleted = savedInstanceState.getInt(Constants.PRACTICE_GAMES_COMPLETED); mPracticeTimeSpent = savedInstanceState.getInt(Constants.PRACTICE_TIME_SPENT); mPracticeHintsUsed = savedInstanceState.getInt(Constants.PRACTICE_HINTS_USED); mPracticePointsEarned = savedInstanceState.getInt(Constants.PRACTICE_POINTS_EARNED); } mGameState = savedInstanceState.getInt(Constants.KEY_GAME_STATE); mGameHintsRemaining = savedInstanceState.getInt(Constants.KEY_GAME_HINTS_REMAINING); mGameHintsUsed = GameUtils.getPointChart(mPlayType, mIsPlay, mLevel, mPracticeType)[GameUtils.GAME_HINTS_TOTAL][mGameType] - mGameHintsRemaining; mGamePoints = savedInstanceState.getInt(Constants.KEY_GAME_POINTS); mGameTime = savedInstanceState.getLong(Constants.KEY_GAME_DURATION); mGameData = savedInstanceState.getString(Constants.KEY_GAME_DATA); } }
From source file:com.wareninja.android.opensource.mongolab_sdk.common.WebService.java
public String webPost(String methodName, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os;/*from w ww . ja va 2 s. c om*/ ret = null; String postUrl = webServiceUrl + methodName; if (AppContext.isDebugMode()) Log.d(TAG, "POST URL: " + postUrl); HttpURLConnection conn = (HttpURLConnection) new URL(postUrl).openConnection(); /*for (RequestHeader header : headers) { if (header != null) { conn.setRequestProperty(header.getKey(), header.getValue()); if (AppContext.isDebugMode()) { Log.d(TAG, String.format("httpDelete.setHeader(%s, %s)", header.getKey(), header.getValue()) ); } } }*/ //if ( TextUtils.isEmpty(conn.getRequestProperty("User-Agent")) ) { conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " WareNinjaAndroidSDK"//"com.wareninja.android.mayormonster"//CommonUtils.getMyUserAgent(mContext)// ); //} Bundle dataparams = new Bundle(); for (String key : params.keySet()) { byte[] byteArr = null; try { byteArr = (byte[]) params.get(key); } catch (Exception ex1) { } if (byteArr != null) dataparams.putByteArray(key, byteArr); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); appendRequestHeaders(conn, headers); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((CommonUtils.encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); String response = ""; try { response = CommonUtils.read(conn.getInputStream()); //mHttpResponseCode = conn.getResponseCode(); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = CommonUtils.read(conn.getErrorStream()); } if (AppContext.isDebugMode()) Log.d(TAG, "POST response: " + response); return response; }
From source file:com.ezeeideas.wordjam.BaseGameActivity.java
/** * The Uber Initialization routine. Call this, and only this, from all games * to ensure correct order of initialization. *//* ww w .ja v a2 s . c om*/ private void initAll(Bundle savedInstanceState) { commonInit(); doInitializeGame(); if (savedInstanceState != null && !savedInstanceState.isEmpty()) { restoreSavedInstance(savedInstanceState); } else if (getIntent().getExtras() != null) { initializeFromExtras(getIntent().getExtras()); } setupViews(); setupInterstitialAds(); setupGame(); setupConnectors(); }
From source file:sg.lt.obs.common.gcm.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { try {//from w w w. j a v a 2 s. co m Bundle extras = intent.getExtras(); mBookingVehicleItemId = extras.getString(ObsConst.KEY_BOOKING_VEHICLE_ITEM_ID); mNotificationContent = extras.getString("title"); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); Boolean isRun = false; // ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); // String packageName = this.getPackageName(); // List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); // if (appProcesses != null) { // for (RunningAppProcessInfo appProcess : appProcesses) { // // The name of the process that this object is associated with. // if (appProcess.processName.equals(packageName) && appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { // isRun = true; // break; // } // } // } if (ActivityStack.getAcitveActivity() != null) { isRun = true; } if (!extras.isEmpty()) { // has effect of unparcelling Bundle //Bundle[{from=1083654704210, title=30/06/2014 20:25 From Changi Airport Singapore Singapore to Boon Keng Road Singapore, mBookingVehicleItemId=8a3080d5457d005a01457f1aeec31aa4, android.support.content.wakelockid=1, collapse_key=do_not_collapse}] if (StringUtil.isNotEmpty(mBookingVehicleItemId)) { // if (isRun && GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // mHandler.obtainMessage(0).sendToTarget(); // } else { /* * 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)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post mNotificationContent of received message. sendNotification(extras.toString()); Log.i(TAG, "Received: " + extras.toString()); } // } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.pressurelabs.flowopensource.TheHubActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_the_hub); /* Set up ActionBar */ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_the_hub); setSupportActionBar(toolbar);/*from w w w. j a va2 s .c o m*/ /* Set up Navigation Drawer */ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.hub_drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); generateDrawerGreeting(navigationView); /* Set up recycler and Card View */ recyclerView = (RecyclerView) findViewById(R.id.recycler_view); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); if (savedInstanceState != null && !savedInstanceState.isEmpty()) { rvContent = savedInstanceState.getParcelableArrayList(AppConstants.RESTORED_USER_FLOWS); manager = savedInstanceState.getParcelable(AppConstants.RESTORED_DATA_MANAGER); } else { rvContent = new ArrayList<>(); manager = new AppDataManager(this); } menuState = AppConstants.MENU_ITEMS_NATIVE; mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Drive.API).addScope(Drive.SCOPE_FILE) .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build(); }