本文整理汇总了Java中android.os.Bundle类的典型用法代码示例。如果您正苦于以下问题:Java Bundle类的具体用法?Java Bundle怎么用?Java Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bundle类属于android.os包,在下文中一共展示了Bundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.os.Bundle; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_main, container, false);
AdView mAdView = (AdView) root.findViewById(R.id.adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device. e.g.
// "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device."
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
return root;
}
示例2: onCreate
import android.os.Bundle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
datas = new ArrayList<>();
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(mAdapter = new HomeAdapter());
getCategoryData();
getCategoryData();
getCategoryData();
mAdapter.notifyDataSetChanged();
}
示例3: onActivityResult
import android.os.Bundle; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
if (Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(this)) {
//SYSTEM_ALERT_WINDOW permission not granted...
Toast.makeText(this, "Permission Denied by user.", Toast.LENGTH_SHORT)
.show();
mSwSms.setChecked(false);
ShareUtil.putBoolean(this, "isSms", mSwSms.isChecked());
} else {
Toast.makeText(this, "Permission allowed", Toast.LENGTH_SHORT).show();
mSwSms.setChecked(true);
ShareUtil.putBoolean(this, "isSms", mSwSms.isChecked());
}
} else if (requestCode == QRCODE_RESULT) {
if (resultCode == RESULT_OK) {
Bundle bundle = data.getExtras();
String scanResult = bundle.getString("result");
mScanResult.setText(scanResult);
}
}
}
示例4: onCreate
import android.os.Bundle; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
DBHandler dbHandler = new DBHandler(getActivity());
liftNames = dbHandler.listAllTables();
DBHandler currentTable;
int value;
for(String liftName: liftNames){
currentTable = new DBHandler(getActivity(), liftName);
currMaxes = currentTable.getAllItems();
value = MaxesAdapter.findLastValue(currentTable, liftName);
if(value != -1){
MaxesCard newMax = new MaxesCard(createTitle(liftName), value);
list.add(newMax);
}
}
dbHandler.close();
}
catch (Exception e){
}
}
示例5: onCreate
import android.os.Bundle; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.activity_home_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.activity_home_toolbar_title);
mViewpager = (ViewPager) findViewById(R.id.activity_home_viewpager);
mTabLayout = (TabLayout) findViewById(R.id.activity_home_tab_layout);
mFab = (FloatingActionButton) findViewById(R.id.activity_home_fab);
mFab.setOnClickListener(this);
setupViewPagerAndTabLayout();
//startNotificationService();
}
示例6: setupServiceReceiver
import android.os.Bundle; //导入依赖的package包/类
public void setupServiceReceiver() {
mReceiver = new DownloadResultReceiver(new Handler());
Intent intent = new Intent(getApplicationContext(), DownloadService.class);
intent.putExtra("receiver", mReceiver);
if(!PreferenceHelper.isSynced(getApplicationContext())) {
startService(intent);
}
// This is where we specify what happens when data is received from the
// service
mReceiver.setReceiver(new DownloadResultReceiver.Receiver() {
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
if (resultCode == RESULT_OK) {
String resultValue = resultData.getString("resultValue");
Toast.makeText(MainActivity.this, resultValue, Toast.LENGTH_SHORT).show();
}
}
});
}
示例7: onCreate
import android.os.Bundle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modos_russa);
botaoVoltar = (Button) findViewById(R.id.botaoVoltarRussa_6);
botaoVoltar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ModosRussaActivity.this, RussaActivity.class);
startActivity(intent);
finish();
}
});
}
示例8: onCreate
import android.os.Bundle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
// .setAction("Action", null).show();
showActionSheet();
}
});
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
示例9: save
import android.os.Bundle; //导入依赖的package包/类
/**
* Persists all supported data types present in the passed in Bundle, to the
* cache
*
* @param bundle
* The Bundle containing information to be cached
*/
public void save(Bundle bundle) {
Validate.notNull(bundle, "bundle");
SharedPreferences.Editor editor = cache.edit();
for (String key : bundle.keySet()) {
try {
serializeKey(key, bundle, editor);
} catch (JSONException e) {
// Error in the bundle. Don't store a partial cache.
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error processing value for key: '" + key + "' -- " + e);
// Bypass the commit and just return. This cancels the entire edit transaction
return;
}
}
boolean successfulCommit = editor.commit();
if (!successfulCommit) {
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "SharedPreferences.Editor.commit() was not successful");
}
}
开发者ID:MobileDev418,项目名称:chat-sdk-android-push-firebase,代码行数:30,代码来源:SharedPreferencesTokenCachingStrategy.java
示例10: onCreateView
import android.os.Bundle; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_click, container, false);
if (null != savedInstanceState) {
mClickCounter = savedInstanceState.getParcelable(CLICK_COUNT_TAG);
} else {
mClickCounter = new ClickCounter();
}
mTextView = (TextView) rootView.findViewById(R.id.click_count_text_view);
displayClickCount();
Button button = (Button) rootView.findViewById(R.id.click_button);
button.setOnClickListener(mListener);
return rootView;
}
示例11: onCreateView
import android.os.Bundle; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_exit, container, false);
mSharedPreferences = getActivity().getSharedPreferences(
"org.greenstand.android", Context.MODE_PRIVATE);
Button yesBtn = (Button) v.findViewById(R.id.fragment_exit_yes);
yesBtn.setOnClickListener(ExitFragment.this);
Button noBtn = (Button) v.findViewById(R.id.fragment_exit_no);
noBtn.setOnClickListener(ExitFragment.this);
return v;
}
示例12: writeToParcel
import android.os.Bundle; //导入依赖的package包/类
@Override
public void writeToParcel(final Parcel parcel, final int arg1) {
final Bundle b = new Bundle(getClass().getClassLoader());
b.putByteArray(PARCEL_EXTRA_DEVICE_SCANRECORD, mScanRecord);
b.putInt(PARCEL_EXTRA_FIRST_RSSI, mFirstRssi);
b.putInt(PARCEL_EXTRA_CURRENT_RSSI, mCurrentRssi);
b.putLong(PARCEL_EXTRA_FIRST_TIMESTAMP, mFirstTimestamp);
b.putLong(PARCEL_EXTRA_CURRENT_TIMESTAMP, mCurrentTimestamp);
b.putParcelable(PARCEL_EXTRA_BLUETOOTH_DEVICE, mDevice);
b.putParcelable(PARCEL_EXTRA_DEVICE_SCANRECORD_STORE, mRecordStore);
b.putSerializable(PARCEL_EXTRA_DEVICE_RSSI_LOG, (Serializable) mRssiLog);
parcel.writeBundle(b);
}
示例13: onCreate
import android.os.Bundle; //导入依赖的package包/类
@Override
@SuppressLint("NewApi")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// External storage permissions
if (Build.VERSION.SDK_INT < 23) {
Log.d(TAG, "Don't need permissions.");
} else {
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
if (shouldShowRequestPermissionRationale(Manifest.permission.READ_EXTERNAL_STORAGE)) {
Log.d(TAG, "PERMISSIONS: App needs permissions to read external storage.");
}
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
}
}
// Create directory for files if it does not exist
File musicFolder = new File(Environment.getExternalStorageDirectory() + File.separator + MUSIC_DIR_NAME);
if (!musicFolder.exists()) {
musicFolder.mkdir();
}
// Get shared prefs
sharedPreferences = getSharedPreferences("com.lunchareas.divertio", MODE_PRIVATE);
}
示例14: onCreate
import android.os.Bundle; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_b);
mActivityName = getString(R.string.activity_b_label);
mStatusView = (TextView)findViewById(R.id.status_view_b);
mStatusAllView = (TextView)findViewById(R.id.status_view_all_b);
mStatusTracker.setStatus(mActivityName, getString(R.string.on_create));
Utils.printStatus(mStatusView, mStatusAllView);
}
示例15: onCreate
import android.os.Bundle; //导入依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dream);
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
lvDream = forceCast(findViewById(R.id.lvDream));
etDream = forceCast(findViewById(R.id.etDream));
etDream.setText(R.string.dream_api_example);
findViewById(R.id.btnSearch).setOnClickListener(this);
dreamList = new ArrayList<HashMap<String,Object>>();
adapter = new DreamSimpleAdapter(this, dreamList);
lvDream.setAdapter(adapter);
}