package com.hyzing;
import android.app.Application;
public class MySystemAppcation extends Application{
private int curIndex;
public int getCurIndex() {
return curIndex;
}
public void setCurIndex(int curIndex) {
this.curIndex = curIndex;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onTerminate() {
super.onTerminate();
}
}
package com.hyzing;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
public class SystemtestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
MySystemAppcation application = (MySystemAppcation) this
.getApplication();
System.out.println("++++++++++++++"+application);
Log.i("data", "===============" + application.getCurIndex());
application.setCurIndex(5);
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("checkIn", "0");
bundle.putBoolean("managerUser", true);
intent.putExtras(bundle);
intent.setClass(SystemtestActivity.this, PrintActivity.class);
startActivity(intent);
}
}
package com.hyzing;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
public class PrintActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MySystemAppcation application = (MySystemAppcation) this
.getApplication();
Log.i("data", "" + application.getCurIndex());
application.setCurIndex(6);
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("checkIn", "0");
bundle.putBoolean("managerUser", true);
intent.putExtras(bundle);
intent.setClass(PrintActivity.this, PrintAgainActivity.class);
startActivity(intent);
}
}
package com.hyzing;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class PrintAgainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final MySystemAppcation application = (MySystemAppcation) this
.getApplication();
Log.i("data", "" + application.getCurIndex());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hyzing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application android:name=".MySystemAppcation"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".SystemtestActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PrintActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".PrintAgainActivity"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
分享到:
相关推荐
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android....
就是全局对象 实用J2EE的读者来说都知道Java Web的四个作用域 这四个作用域从小到大分别是Page Request Session和Application 其中Application域在应用程序的任何地方都可以使用和访问 除非是Web服务器停止 Android...
YLC APPLICATION app YLC APPLICATION this getApplication ; setContentView R layout activity ylc bus line ; 地图初始化 mMapView MapView findViewById R id bmapView ; mMapView getController ...
FloatMenuSample [ ] transfer from GIF GRADLE: ... // .withContext(mActivity.getApplication())//这个在7.0(包括7.0)以上以及大部分7.0以下的国产手机上需要用户授权,需要搭配<uses-permission
CameraManager.init(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); hasSurface = false; inactivityTimer = new InactivityTimer(this); } @Override ...
使用方法:public void getScreen() { String filename = getApplication().getFilesDir().toString() + "test.png"; ScreentShotUtil.getInstance().takeScreenshot(getApplicationContext(), filename); } 把...
简单的方法是使用左上角协调来定位 android 视图。 在您的设计 UI 上使用协调,它将转换为您想要显示的大小或设备显示大小。 用法 ###Programmatically SimpleLayout layout = new SimpleLayout(getApplication());...
Android 指定手机号的手机震动模式自定义实例,请看以下的代码片段: RadioButton rbMeeting;//会议模式 RadioButton rbNormal;//正常模式 Button bAdd;//添加按钮 EditText et;//输入框 TextView tv;//...
使用Vibrator的vibrate()可调节震动时间;cancel()取消震动。 代码如下: <!—震动权限–> <uses android:name=”android.permission.VIBRATE”/> //振动器实例化 private Vibrator mVibrator1; mVibrator1=...
Notificationandroid 5.0 lollipop HeadsUp Notification with Eclipse edition from #2.0 使用库实现类似的方法(向下兼容2.3)#下面介绍一个自己写的,类似 Heads-up 组件的库.simple heads-up (no expand)使用方法: ...
在Android中,很多人会用如下的方法判断当前网络是否可用: /** * 获取当前网络状态(是否可用) */ public static boolean isNetworkAvailable() { boolean isAalable = false; ConnectivityManager connManager = ...
详细总结了Context是什么?Android系统中Context的继承关系,不同Context源码分析,Context应用场景,getApplication和getApplicationContext区别。
Fresco.initialize(getApplication())报错 failed resolution of: landroidx/core/util/pools$synchronizedpool;