Java Code Examples for android.os.Bundle.getStringArrayList()

The following are Jave code examples for showing how to use getStringArrayList() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: QuranAndroid   File: DownloadTafseerService.java   View Source Code Vote up 7 votes
/**
 * Function to start service
 *
 * @param intent  Activity intent
 * @param flags   to start sticky or not
 * @param startId Service id
 * @return usually start or start once
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("TAFSEER_DOWN_TAG" , "tafseer service is start");
    AppPreference.Downloading(true);
    Bundle extras = intent.getExtras();
    String downloadURL = extras.getString(AppConstants.Download.DOWNLOAD_URL);
    String downloadLocation = extras.getString(AppConstants.Download.DOWNLOAD_LOCATION);
    int type = extras.getInt(AppConstants.Download.TYPE , -1);
    List<String> downloadLinks = extras.getStringArrayList(AppConstants.Download.DOWNLOAD_LINKS);

    if(downloadLinks == null){
            downloadManager = new DownloadManager(this, true ,type);
            downloadManager.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, downloadURL, downloadLocation);
    } else{
            downloadManager = new DownloadManager(this, true, downloadLinks ,type);
            downloadManager.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "", downloadLocation);
    }

    return START_NOT_STICKY;
}
 
Example 2
Project: thesis-project   File: ExamInputAdapter.java   View Source Code Vote up 6 votes
@Override
public void onResults(Bundle results) {
    ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    int number = 0;
    for (String result : matches) {
        try {
            number = Integer.parseInt(result);
            break;
        } catch (NumberFormatException e) {
            e.printStackTrace();
            number = 0;
        }
    }
    editText.setText(number + "");
    isActivated = false;
}
 
Example 3
Project: kognitivo   File: LoginMethodHandler.java   View Source Code Vote up 6 votes
static AccessToken createAccessTokenFromNativeLogin(
        Bundle bundle,
        AccessTokenSource source,
        String applicationId) {
    Date expires = Utility.getBundleLongAsDate(
            bundle, NativeProtocol.EXTRA_EXPIRES_SECONDS_SINCE_EPOCH, new Date(0));
    ArrayList<String> permissions = bundle.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
    String token = bundle.getString(NativeProtocol.EXTRA_ACCESS_TOKEN);

    if (Utility.isNullOrEmpty(token)) {
        return null;
    }

    String userId = bundle.getString(NativeProtocol.EXTRA_USER_ID);

    return new AccessToken(
            token,
            applicationId,
            userId,
            permissions,
            null,
            source,
            expires,
            new Date());
}
 
Example 4
Project: MyDemo   File: WelfareDetailActivity.java   View Source Code Vote up 6 votes
@Override
protected void initViews() {
    Bundle bundle = getIntent().getExtras();
    currentPos = bundle.getInt("position");
    imgList = bundle.getStringArrayList("imgList");
    mPresenter = new WelfareDetailPresenterImpl(this);
    mAdapter = new WelfareDetailPageAdapter(this, imgList, mPresenter);
    mViewPager.setAdapter(mAdapter);
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
        @Override
        public void onPageSelected(int position) {
            currentPos = position;
            tvIndex.setText(currentPos+1+" / " +imgList.size());
        }
    });
    registerActivityFinish();
}
 
Example 5
Project: QuranAndroid   File: DownloadService.java   View Source Code Vote up 6 votes
/**
 * Function to start service
 *
 * @param intent  Activity intent
 * @param flags   to start sticky or not
 * @param startId Service id
 * @return usually start or start once
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    AppPreference.Downloading(true);
    Bundle extras = intent.getExtras();
    String downloadURL = extras.getString(AppConstants.Download.DOWNLOAD_URL);
    String downloadLocation = extras.getString(AppConstants.Download.DOWNLOAD_LOCATION);
    List<String> downloadLinks = extras.getStringArrayList(AppConstants.Download.DOWNLOAD_LINKS);

    if(downloadLinks == null){
        downloadManager = new DownloadManager(this, true);
        downloadManager.execute(downloadURL, downloadLocation);
    } else{
        downloadManager = new DownloadManager(this, true , downloadLinks);
        downloadManager.execute("", downloadLocation);
    }

    return START_NOT_STICKY;
}
 
Example 6
Project: thesis-project   File: QuizInputAdapterF.java   View Source Code Vote up 6 votes
@Override
public void onResults(Bundle results) {
    ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    int number = 0;
    for (String result : matches) {
        try {
            number = Integer.parseInt(result);
            break;
        } catch (NumberFormatException e) {
            e.printStackTrace();
            number = 0;
        }
    }
    editText.setText(number + "");
    isActivated = false;
}
 
Example 7
Project: Saiy-PS   File: SelfAwareConditions.java   View Source Code Vote up 6 votes
/**
 * Add the recognition results to the existing {@link Bundle}
 *
 * @param results recognition results {@link Bundle}
 */
public void putResults(@NonNull final Bundle results) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "putResults");
    }

    final ArrayList<String> heardVoice = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    final float[] confidence = results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES);

    if (heardVoice != null) {
        getBundle().putStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION, heardVoice);
    } else {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "putResults: speech empty");
        }
        getBundle().putStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION, new ArrayList<String>());
    }

    if (confidence != null) {
        getBundle().putFloatArray(SpeechRecognizer.CONFIDENCE_SCORES, confidence);
    } else {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "putResults: confidence empty");
        }
        getBundle().putFloatArray(SpeechRecognizer.CONFIDENCE_SCORES, new float[0]);
    }
}
 
Example 8
Project: CustomAndroidOneSheeld   File: SpeechRecognition.java   View Source Code Vote up 5 votes
private void receiveResults(Bundle results) {
    if ((results != null)
            && results.containsKey(SpeechRecognizer.RESULTS_RECOGNITION)) {
        List<String> res = results
                .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
        if (mResultCallback != null)
            mResultCallback.onResult(res);
    }
}
 
Example 9
Project: chat-sdk-android-push-firebase   File: AuthorizationClient.java   View Source Code Vote up 5 votes
void getTokenCompleted(AuthorizationRequest request, Bundle result) {
    getTokenClient = null;

    notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions = result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        List<String> permissions = request.getPermissions();
        if ((currentPermissions != null) &&
                ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            AccessToken token = AccessToken
                    .createFromNativeLogin(result, AccessTokenSource.FACEBOOK_APPLICATION_SERVICE);
            Result outcome = Result.createTokenResult(pendingRequest, token);
            completeAndValidate(outcome);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the permissions
        // we still need.
        List<String> newPermissions = new ArrayList<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        if (!newPermissions.isEmpty()) {
            addLoggingExtra(EVENT_EXTRAS_NEW_PERMISSIONS, TextUtils.join(",", newPermissions));
        }

        request.setPermissions(newPermissions);
    }

    tryNextHandler();
}
 
Example 10
Project: chat-sdk-android-push-firebase   File: AccessToken.java   View Source Code Vote up 5 votes
static AccessToken createFromNativeLogin(Bundle bundle, AccessTokenSource source) {
    Date expires = getBundleLongAsDate(
            bundle, NativeProtocol.EXTRA_EXPIRES_SECONDS_SINCE_EPOCH, new Date(0));
    ArrayList<String> permissions = bundle.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
    String token = bundle.getString(NativeProtocol.EXTRA_ACCESS_TOKEN);

    return createNew(permissions, token, expires, source);
}
 
Example 11
Project: QMark   File: ContributeActy.java   View Source Code Vote up 5 votes
private void restoreInstanceStateInner(Bundle savedInstanceState) {
	L.d(ContributeActy.class, "restoreInstanceStateInner---------");
	mFromFeedback = savedInstanceState.getBoolean(EXTRA_FROM_FEEDBACK, false);
	ArrayList<String> value = savedInstanceState.getStringArrayList(EXTRA_LIST_DATA);
	if (value != null && value.size() > 0) {
		List<Uri> data = new ArrayList<Uri>();
		for (String s : value) {
			data.add(Uri.parse(s));
		}
		getAdapter().setDataSource(data);
	}
	String json = savedInstanceState.getString(EXTRA_SESSION);
	if (json != null) session = Session.fromJsonWithAllFields(json, Session.class);
}
 
Example 12
Project: letv   File: QzoneShare.java   View Source Code Vote up 5 votes
private StringBuffer a(StringBuffer stringBuffer, Bundle bundle) {
    f.c(f.d, "fillShareToQQParams() --start");
    ArrayList stringArrayList = bundle.getStringArrayList("imageUrl");
    Object string = bundle.getString("appName");
    int i = bundle.getInt("req_type", 1);
    String string2 = bundle.getString("title");
    String string3 = bundle.getString("summary");
    bundle.putString("appId", this.mToken.getAppId());
    bundle.putString("sdkp", "a");
    bundle.putString("sdkv", Constants.SDK_VERSION);
    bundle.putString("status_os", VERSION.RELEASE);
    bundle.putString("status_machine", Build.MODEL);
    String str = "...";
    if (!Util.isEmpty(string2) && string2.length() > 40) {
        bundle.putString("title", string2.substring(0, 40) + "...");
    }
    if (!Util.isEmpty(string3) && string3.length() > 80) {
        bundle.putString("summary", string3.substring(0, 80) + "...");
    }
    if (!TextUtils.isEmpty(string)) {
        bundle.putString("site", string);
    }
    if (stringArrayList != null) {
        int size = stringArrayList.size();
        String[] strArr = new String[size];
        for (int i2 = 0; i2 < size; i2++) {
            strArr[i2] = (String) stringArrayList.get(i2);
        }
        bundle.putStringArray("imageUrl", strArr);
    }
    bundle.putString("type", String.valueOf(i));
    stringBuffer.append("&" + Util.encodeUrl(bundle).replaceAll("\\+", "%20"));
    f.c(f.d, "fillShareToQQParams() --end");
    return stringBuffer;
}
 
Example 13
Project: FBEventSync   File: PermissionRequestActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle extras = getIntent().getExtras();
    ArrayList<String> missingPerms = extras.getStringArrayList(MISSING_PERMISSIONS);

    ActivityCompat.requestPermissions(this,missingPerms.toArray(new String[missingPerms.size()]),
                                      PERMISSION_REQUEST_ID);
}
 
Example 14
Project: CouponsTracker   File: CouponListFragment.java   View Source Code Vote up 5 votes
private void restoreSavedInstanceState(Bundle savedInstanceState) {
    DebugLog.logMethod();
    if (savedInstanceState == null) {
        DebugLog.logMessage("savedInstanceState null");
        merchants = new ArrayList<>();
        categories = new ArrayList<>();
        return;
    }

    DebugLog.logMessage("restoring savedInstanceState");
    coupons = savedInstanceState.getParcelableArrayList(Constants.BUNDLE_EXTRA_COUPONS);
    listPosition = Math.max(0, savedInstanceState.getInt(Constants.BUNDLE_EXTRA_LIST_POSITION));
    merchants = savedInstanceState.getStringArrayList(Constants.BUNDLE_EXTRA_MERCHANT_SUGGESTIONS);
    categories = savedInstanceState.getStringArrayList(Constants.BUNDLE_EXTRA_CATEGORY_SUGGESTIONS);
}
 
Example 15
Project: HutHelper   File: ShowImageActivity.java   View Source Code Vote up 5 votes
@Override
protected void initBundleData(Bundle bundle) {
    images = bundle.getStringArrayList("images");
    currentPosition = bundle.getInt("curr");
    if (ListUtils.isEmpty(images)) {
        ToastUtil.showToastShort("获取数据出错");
        finish();
    }
}
 
Example 16
Project: Camera-Roll-Android-App   File: SelectorModeManager.java   View Source Code Vote up 5 votes
public SelectorModeManager(Bundle savedState) {
    if (savedState.containsKey(SELECTOR_MODE_ACTIVE)) {
        setSelectorMode(Boolean.parseBoolean(savedState.getString(SELECTOR_MODE_ACTIVE)));
    }

    if (isSelectorModeActive() && savedState.containsKey(SELECTED_ITEMS_PATHS)) {
        selected_items_paths = savedState.getStringArrayList(SELECTED_ITEMS_PATHS);
    } else {
        selected_items_paths = new ArrayList<>();
    }
}
 
Example 17
Project: garras   File: IabHelper.java   View Source Code Vote up 4 votes
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;

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(),
                itemType, continueToken);

        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;
}
 
Example 18
Project: react-native-cafe-bazaar   File: IabHelper.java   View Source Code Vote up 4 votes
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;

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(),
                itemType, continueToken);

        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;
}
 
Example 19
Project: TaBeTa   File: ClaSSePA.java   View Source Code Vote up 4 votes
int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
                            throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(),
            itemType, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        }
        else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(
            RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}
 
Example 20
Project: chat-sdk-android-push-firebase   File: TokenCachingStrategy.java   View Source Code Vote up 2 votes
/**
 * Gets the cached list of permissions from a Bundle.
 * 
 * @param bundle
 *            A Bundle in which the list of permissions was stored.
 * @return the cached list of permissions.
 *
 * @throws NullPointerException if the passed in Bundle is null
 */
public static List<String> getPermissions(Bundle bundle) {
    Validate.notNull(bundle, "bundle");
    return bundle.getStringArrayList(PERMISSIONS_KEY);
}