Application使用

Java代码   收藏代码
  1. package com.hyzing;  
  2.   
  3. import android.app.Application;  
  4.   
  5. public class MySystemAppcation extends Application{  
  6.     private int curIndex;  
  7.   
  8.     public int getCurIndex() {  
  9.         return curIndex;  
  10.     }  
  11.   
  12.     public void setCurIndex(int curIndex) {  
  13.         this.curIndex = curIndex;  
  14.     }  
  15.   
  16.     @Override  
  17.     public void onCreate() {  
  18.         super.onCreate();  
  19.     }  
  20.   
  21.     @Override  
  22.     public void onTerminate() {  
  23.         super.onTerminate();  
  24.     }  
  25. }  
Java代码   收藏代码
  1. package com.hyzing;  
  2. import android.app.Activity;  
  3. import android.content.Intent;  
  4. import android.os.Bundle;  
  5. import android.util.Log;  
  6.   
  7. public class SystemtestActivity extends Activity {  
  8.     @Override  
  9.     public void onCreate(Bundle savedInstanceState) {  
  10.         super.onCreate(savedInstanceState);  
  11.         //setContentView(R.layout.main);      
  12.         MySystemAppcation application = (MySystemAppcation) this  
  13.                 .getApplication();  
  14.         System.out.println("++++++++++++++"+application);  
  15.         Log.i("data""===============" + application.getCurIndex());  
  16.         application.setCurIndex(5);  
  17.         Intent intent = new Intent();  
  18.         Bundle bundle = new Bundle();  
  19.         bundle.putString("checkIn""0");  
  20.         bundle.putBoolean("managerUser"true);  
  21.         intent.putExtras(bundle);  
  22.         intent.setClass(<span style="color: #ff0000;">SystemtestActivity.this</span>, PrintActivity.class);  
  23.         startActivity(intent);  
  24.           
  25.     }  
  26. }  
Java代码   收藏代码
  1. package com.hyzing;  
  2.   
  3. import android.app.Activity;  
  4. import android.content.Intent;  
  5. import android.os.Bundle;  
  6. import android.util.Log;  
  7.   
  8. public class PrintActivity extends Activity {  
  9.   
  10.     @Override  
  11.     protected void onCreate(Bundle savedInstanceState) {  
  12.         <span style="color: #ff0000;">super.onCreate(savedInstanceState);</span>  
  13.         MySystemAppcation application = (MySystemAppcation) this  
  14.                 .getApplication();  
  15.         Log.i("data""" + application.getCurIndex());  
  16.         application.setCurIndex(6);  
  17.         Intent intent = new Intent();  
  18.         Bundle bundle = new Bundle();  
  19.         bundle.putString("checkIn""0");  
  20.         bundle.putBoolean("managerUser"true);  
  21.         intent.putExtras(bundle);  
  22.         intent.setClass(PrintActivity.this, PrintAgainActivity.class);  
  23.         startActivity(intent);  
  24.     }  
  25. }  

Java代码   收藏代码
  1. package com.hyzing;  
  2.   
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5. import android.util.Log;  
  6.   
  7. public class PrintAgainActivity extends Activity {  
  8.   
  9.     @Override  
  10.     protected void onCreate(Bundle savedInstanceState) {  
  11.         <span style="color: #ff0000;">super.onCreate(savedInstanceState);</span>  
  12.         final MySystemAppcation application = (MySystemAppcation) this  
  13.                 .getApplication();  
  14.         Log.i("data""" + application.getCurIndex());  
  15.   
  16.     }  
  17.   
  18. }  

Java代码   收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     package="com.hyzing"  
  4.     android:versionCode="1"  
  5.     android:versionName="1.0" >  
  6.   
  7.     <uses-sdk android:minSdkVersion="15" />  
  8.     <application android:name=".MySystemAppcation"  
  9.         android:icon="@drawable/ic_launcher"  
  10.         android:label="@string/app_name" >  
  11.         <activity  
  12.             android:name=".SystemtestActivity"  
  13.             android:label="@string/app_name" >  
  14.             <intent-filter>  
  15.                 <action android:name="android.intent.action.MAIN" />  
  16.                 <category android:name="android.intent.category.LAUNCHER" />  
  17.             </intent-filter>  
  18.         </activity>  
  19.         <activity  
  20.             android:name=".PrintActivity"  
  21.             android:label="@string/app_name" >              
  22.         </activity>  
  23.         <activity  
  24.             android:name=".PrintAgainActivity"  
  25.             android:label="@string/app_name" >              
  26.         </activity>  
  27.           
  28.     </application>  
  29.   
  30. </manifest>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值