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

The following are Jave code examples for showing how to use getString() 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: letv   File: ApiKey.java   View Source Code Vote up 6 votes
protected String getApiKeyFromManifest(Context context) {
    String apiKey = null;
    try {
        Bundle bundle = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData;
        if (bundle != null) {
            apiKey = bundle.getString(FABRIC_API_KEY);
            if (apiKey == null) {
                Fabric.getLogger().d(Fabric.TAG, "Falling back to Crashlytics key lookup from Manifest");
                apiKey = bundle.getString(CRASHLYTICS_API_KEY);
            }
        }
    } catch (Exception e) {
        Fabric.getLogger().d(Fabric.TAG, "Caught non-fatal exception while retrieving apiKey: " + e);
    }
    return apiKey;
}
 
Example 2
Project: CXJPadProject   File: ScanResultOrderFragment.java   View Source Code Vote up 6 votes
@Override
public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
    super.onFragmentResult(requestCode, resultCode, data);
    switch (requestCode) {
        case HomeFragment.REQUEST_CODE_NEW_CAR:
            if (resultCode == RESULT_OK) {
                UpdateCustomerModel model = (UpdateCustomerModel) data.getSerializable("UpdateCustomerModel");
                requestModel = QueryCustAndOrderInfoModel.buildSingle(model.plates, model.custId, model.custVelId, model.cxId, null, model.mobile, model.custName);
                loadData();
            } else if (resultCode == UseMsgFragment.RESULT_CODE_CHANGE_MOBILE) {
                requestModel.mobile = data.getString("mobile");
                loadData();
            }
            break;
        default:
            loadData();
            break;
    }
}
 
Example 3
Project: AppFirCloud   File: DownLoadService.java   View Source Code Vote up 6 votes
@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            apkName = extras.getString("name");
            downloadUrl = extras.getString("downloadurl");
            Logger.i("DownLoadService: %s", apkName + "\r\n" + downloadUrl);
//            downloadUrl = "http://pro-app-qn.fir.im/f63088ce552e398521ce5840de798c803b29dd2c.apk?attname=appcloud-v1.0.0-huawei-release.apk_V1.0.0.apk&e=1513073607&token=LOvmia8oXF4xnLh0IdH05XMYpH6ENHNpARlmPc-T:zlbPNpvxSrX779NlvRQW0kTjPr0=";
            apkName = apkName + "_" + Long.toString(System.currentTimeMillis() / 1000) + ".apk";
            Log.i(TAG, "apkName: " + apkName);
        }

        //如果路径下apk文件存在,就删除
        File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), apkName);
        if (file.exists()) {
            file.delete();
        }

        //创建广播对象并注册广播,用于监听下载完成后自动安装APK
        mReceiver = new DownloadCompleteReceiver();
        registerReceiver(mReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

        //下载需要写SD卡权限, targetSdkVersion>=23 需要动态申请权限
        applyPermissions();

        return Service.START_STICKY;
    }
 
Example 4
Project: AnimatedRecyclerView   File: SampleFragment.java   View Source Code Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    Bundle args = getArguments();
    String title = "Sample";
    int layout = R.layout.fragment_list_from_bottom;
    if (args != null) {
        title = args.getString(SampleActivity.TITLE_KEY);
        layout = args.getInt(SampleActivity.LAYOUT_KEY);
    }

    ((SampleActivity) getActivity()).getSupportActionBar().setTitle(title);

    View view = inflater.inflate(layout, container, false);
    RecyclerView recyclerView = (AnimatedRecyclerView) view.findViewById(R.id.recycler_view);
    recyclerView.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    recyclerView.scheduleLayoutAnimation();

    return view;
}
 
Example 5
Project: Quran   File: FragmentStatePagerAdapter.java   View Source Code Vote up 5 votes
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
  if (state != null) {
    Bundle bundle = (Bundle) state;
    bundle.setClassLoader(loader);
    mSavedState.clear();
    mFragments.clear();

    String lastMode = bundle.getString("mode", "");
    if (!mode.equals(lastMode)) {
      cleanupOldFragments(bundle);
      return;
    }

    Parcelable[] fss = bundle.getParcelableArray("states");
    if (fss != null) {
      for (Parcelable fs : fss) {
        mSavedState.add((Fragment.SavedState) fs);
      }
    }
    Iterable<String> keys = bundle.keySet();
    for (String key : keys) {
      if (key.startsWith("f")) {
        int index = Integer.parseInt(key.substring(1));
        Fragment f = mFragmentManager.getFragment(bundle, key);
        if (f != null) {
          while (mFragments.size() <= index) {
            mFragments.add(null);
          }
          f.setMenuVisibility(false);
          mFragments.set(index, f);
        } else {
          Timber.w("Bad fragment at key %s", key);
        }
      }
    }
  }
}
 
Example 6
Project: MakiLite   File: CustomShortcutActivity.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String url = "";
    String name = "";

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();

    if (extras != null) {
        if (extras.containsKey(URL_FIELD) && extras.containsKey(NAME_FIELD)) {
            url = extras.getString(URL_FIELD);
            name = extras.getString(NAME_FIELD);
        } else {
            finish();
        }
    } else {
        finish();
    }

    Log.v("Installing shortcut", url + ", " + name);
    Intent shortcutIntent = new Intent(getApplicationContext(), ShortcutActivity.class);
    shortcutIntent.putExtra("start_url", url);
    shortcutIntent.setAction(Intent.ACTION_MAIN);
    Intent addIntent = new Intent();
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(getApplicationContext(),
                    R.mipmap.ic_launcher));
    addIntent.setAction(ACTION);
    getApplicationContext().sendBroadcast(addIntent);

    finish();
}
 
Example 7
Project: spline   File: EditorActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.activity_editor);
    setSupportActionBar(mBinding.toolbar);

    String fileName = "untitled.json";
    Bundle bundle = getIntent().getExtras();
    if (bundle != null && bundle.getString(FILENAME) != null) {
        fileName = bundle.getString(FILENAME);
    }

    mViewModel = new DocumentViewModel(this, fileName);
    mViewModel.loadDocument();

    mBinding.setViewModel(mViewModel);


    // Do some necessary non-data binding view work

    // TaskDescription constructor requires us to specify an overview title bar color, so we
    // grab primary color to match the original color
    int primaryColor = getColor(R.color.colorPrimary);
    ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
            mViewModel.getPrettyFileName(), null, primaryColor
    );

    // Set our overview task description with custom name matching the current doc file name
    setTaskDescription(td);

    mLayerTypePopup = new PopupMenu(this, mBinding.addLayerBtn);
    mLayerTypePopup.getMenuInflater().inflate(
            R.menu.menu_layer_types, mLayerTypePopup.getMenu());
    mLayerTypePopup.setOnMenuItemClickListener(mViewModel.getOnMenuItemClickListener());

    registerForContextMenu(mBinding.documentView);
    registerForContextMenu(mBinding.layerList);
}
 
Example 8
Project: Elements   File: BaseSource.java   View Source Code Vote up 5 votes
@Override
protected void onPageStateRestored(Pager.Page page, List<Object> restoredElements, Bundle state) {
    super.onPageStateRestored(page, restoredElements, state);
    String prefix = "__page:"+page.getPageNumber()+":";
    int count = state.getInt(prefix+"placeholderCount", 0);
    if (count == 0) return;
    for (int i = 0; i < restoredElements.size() + count; i++) {
        String is = state.getString(prefix+"pos:"+i+":placeholder", null);
        if (is == null) continue;
        Placeholder placeholder = Placeholder.valueOf(is);
        restoredElements.add(i, placeholder);
    }
}
 
Example 9
Project: gvsig-mobile   File: SpatialiteExporterActivity.java   View Source Code Vote up 5 votes
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.webdatauploadlist);

    Bundle extras = getIntent().getExtras();
    user = extras.getString(PREFS_KEY_USER);
    pwd = extras.getString(PREFS_KEY_PWD);
    url = extras.getString(PREFS_KEY_URL);
    databases = extras.getStringArray(DATABASE_ID);

    refreshList();
}
 
Example 10
Project: AmenEye   File: ZhihuStoryInfoActivity.java   View Source Code Vote up 5 votes
private void initData() {
    Bundle bundle = getIntent().getExtras();
    story_id = String.valueOf(bundle.getInt(Constants.BUNDLE_KEY_ID));
    String title = bundle.getString(Constants.BUNDLE_KEY_TITLE);
    loadZhihuStory();
    mToolbarTitle.setText(title);
    mToolbarTitle.setSelected(true);
}
 
Example 11
Project: CSipSimple   File: RewriterPlugin.java   View Source Code Vote up 5 votes
@Override
public void onReceive(Context context, Intent intent) {
    Log.d(THIS_FILE, "Rewriter receive");
    Bundle resolvedInfos = getResultExtras(true);
    result = resolvedInfos.getString(Intent.EXTRA_PHONE_NUMBER);
    Log.d(THIS_FILE, "Rewriter receive : " + result);
    runSemaphore.release();
}
 
Example 12
Project: MyAnimeViewer   File: ParseAnimeService.java   View Source Code Vote up 5 votes
@Override
public void handleMessage(Message msg) {
    try {
        Bundle extras = msg.getData();

        if (extras != null) {
            final String animeURL = extras.getString(Constants.ANIME_URL);
            int mType = Parser.getTypeByURL(animeURL);
            WriteLog.appendLog(mTag, "parsing " + animeURL);
            if (mType == -1)
                return;

            showNotification(animeURL);
            mParser = Parser.getExistingInstance(mType);
            if (Parser.isDeadSource(mParser)) {
                if (MAVApplication.getInstance().getRepository().isFavorite(animeURL)) {
                    FavoriteRecord lRecord = MAVApplication.getInstance().getRepository().getFavoriteByAnimeUrl(animeURL);
                    MAVApplication.getInstance().getRepository().deleteFavorite(animeURL);
                }
                return;
            }
            if (mParser.isCloudFlareDDOSEnabled) {
                webview = new WebView(mService.get());
                WebSettings websettings = webview.getSettings();
                websettings.setJavaScriptEnabled(true);
                webview.setWebViewClient(new ParserWebClient(animeURL));
                webview.loadUrl(mParser.getServerUrl());
            } else {
                parseData(animeURL);
            }
        }
    } finally {
        PowerManager.WakeLock lock = getLock(mContext);

        if (lock.isHeld()) {
            lock.release();
        }
    }
}
 
Example 13
Project: UpdogFarmer   File: BlacklistDialog.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    preference = (BlacklistPreference) getPreference();
    if (savedInstanceState == null) {
        currentValue = preference.getValue();
    } else {
        currentValue = savedInstanceState.getString(VALUE);
    }
}
 
Example 14
Project: androidtv-sample   File: PlaybackOverlayFragment.java   View Source Code Vote up 5 votes
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    switch (id) {
        case RECOMMENDED_VIDEOS_LOADER: // Fall through.
        case QUEUE_VIDEOS_LOADER: {
            String category = args.getString(VideoContract.VideoEntry.COLUMN_CATEGORY);
            return new CursorLoader(
                    getActivity(),
                    VideoContract.VideoEntry.CONTENT_URI,
                    null, // Projection to return - null means return all fields.
                    VideoContract.VideoEntry.COLUMN_CATEGORY + " = ?",
                    // Selection clause is category.
                    new String[]{category}, // Select based on the category.
                    null // Default sort order
            );
        }
        default: {
            // Loading a specific video.
            String videoId = args.getString(VideoContract.VideoEntry._ID);
            return new CursorLoader(
                    getActivity(),
                    VideoContract.VideoEntry.CONTENT_URI,
                    null, // Projection to return - null means return all fields.
                    VideoContract.VideoEntry._ID + " = ?", // Selection clause is id.
                    new String[]{videoId}, // Select based on the id.
                    null // Default sort order
            );
        }
    }
}
 
Example 15
Project: PureNews   File: VideoFragment.java   View Source Code Vote up 5 votes
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    if (args != null) {
        mID = args.getString("mID");
    }
}
 
Example 16
Project: androidtv-sample   File: SyncAdapter.java   View Source Code Vote up 5 votes
/**
 * Called periodically by the system in every {@code FULL_SYNC_FREQUENCY_SEC}.
 */
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
        ContentProviderClient provider, SyncResult syncResult) {
    Log.d(TAG, "onPerformSync(" + account + ", " + authority + ", " + extras + ")");
    String inputId = extras.getString(SyncAdapter.BUNDLE_KEY_INPUT_ID);
    if (inputId == null) {
        return;
    }
    XmlTvParser.TvListing listings = RichFeedUtil.getRichTvListings(mContext);
    LongSparseArray<XmlTvParser.XmlTvChannel> channelMap = TvContractUtils.buildChannelMap(
            mContext.getContentResolver(), inputId, listings.channels);
    boolean currentProgramOnly = extras.getBoolean(
            SyncAdapter.BUNDLE_KEY_CURRENT_PROGRAM_ONLY, false);
    long startMs = System.currentTimeMillis();
    long endMs = startMs + FULL_SYNC_WINDOW_SEC * 1000;
    if (currentProgramOnly) {
        // This is requested from the setup activity, in this case, users don't need to wait for
        // the full sync. Sync the current programs first and do the full sync later in the
        // background.
        endMs = startMs + SHORT_SYNC_WINDOW_SEC * 1000;
    }
    for (int i = 0; i < channelMap.size(); ++i) {
        Uri channelUri = TvContract.buildChannelUri(channelMap.keyAt(i));
        List<Program> programs = getPrograms(channelUri, channelMap.valueAt(i),
                listings.programs, startMs, endMs);
        updatePrograms(channelUri, programs);
    }
}
 
Example 17
Project: AndroidNetwork   File: LoginActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_login);

	loginTimes = -1;

	Bundle bundle = getIntent().getExtras();
	strEmail = bundle.getString(AppConstants.Email);

	// 使用全局变量的方式传值
	CinemaBean cinema = GlobalVariables.Cinema;
	if (cinema != null) {
		cinemaName = cinema.getCinemaName();
	} else {
		cinemaName = "";
	}

	etEmail = (EditText) findViewById(R.id.email);
	etEmail.setText(strEmail);
	etPassword = (EditText) findViewById(R.id.password);

	// 登录事件
	Button btnLogin = (Button) findViewById(R.id.sign_in_button);
	btnLogin.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			gotoLoginActivity();
		}
	});

	// 获取2个MobileAPI,获取天气数据,获取城市数据
	loadWeatherData();
	loadCityData();
}
 
Example 18
Project: kognitivo   File: WebDialog.java   View Source Code Vote up 4 votes
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    Utility.logd(LOG_TAG, "Redirect URL: " + url);
    if (url.startsWith(WebDialog.this.expectedRedirectUrl)) {
        Bundle values = parseResponseUri(url);

        String error = values.getString("error");
        if (error == null) {
            error = values.getString("error_type");
        }

        String errorMessage = values.getString("error_msg");
        if (errorMessage == null) {
            errorMessage = values.getString("error_message");
        }
        if (errorMessage == null) {
            errorMessage = values.getString("error_description");
        }
        String errorCodeString = values.getString("error_code");
        int errorCode = FacebookRequestError.INVALID_ERROR_CODE;
        if (!Utility.isNullOrEmpty(errorCodeString)) {
            try {
                errorCode = Integer.parseInt(errorCodeString);
            } catch (NumberFormatException ex) {
                errorCode = FacebookRequestError.INVALID_ERROR_CODE;
            }
        }

        if (Utility.isNullOrEmpty(error) && Utility
                .isNullOrEmpty(errorMessage) && errorCode == FacebookRequestError.INVALID_ERROR_CODE) {
            sendSuccessToListener(values);
        } else if (error != null && (error.equals("access_denied") ||
                error.equals("OAuthAccessDeniedException"))) {
            cancel();
        } else if (errorCode == API_EC_DIALOG_CANCEL) {
            cancel();
        } else {
            FacebookRequestError requestError = new FacebookRequestError(errorCode, error, errorMessage);
            sendErrorToListener(new FacebookServiceException(requestError, errorMessage));
        }
        return true;
    } else if (url.startsWith(WebDialog.CANCEL_URI)) {
        cancel();
        return true;
    } else if (url.contains(DISPLAY_TOUCH)) {
        return false;
    }
    // launch non-dialog URLs in a full browser
    try {
        getContext().startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return true;
    } catch (ActivityNotFoundException e) {
        return false;
    }
}
 
Example 19
Project: PlusGram   File: takSettings.java   View Source Code Vote up 4 votes
@Override
public void restoreSelfArgs(Bundle args) {
    if (avatarUpdater != null) {
        avatarUpdater.currentPicturePath = args.getString("path");
    }
}
 
Example 20
Project: Recognize-it   File: AlbumNullFragment.java   View Source Code Vote up 2 votes
/**
 * Resolve the image path at the time of success.
 *
 * @param bundle {@link #onFragmentResult(int, int, Bundle)}.
 * @return image path.
 */
public static String parseImagePath(Bundle bundle) {
    return bundle.getString(KEY_OUTPUT_IMAGE_PATH);
}