public class MyApp extends Application {              private String myState;              public String getState(){          return myState;        }        public void setState(String s){          myState = s;        }      }        public class Blah extends Activity {              @Override        public void onCreate(Bundle b){          ...          MyApp appState = ((MyApp)getApplicationContext());          String state = appState.getState();          ...        }      } 

然后再manifest中添加应用:

    <application android:name=".MyApp" android:icon="@drawable/icon" android:label="@string/app_name">              <activity android:name=".ClickableListItemActivity"                        android:label="@string/app_name">                  <intent-filter>                      <action android:name="android.intent.action.MAIN" />                      <category android:name="android.intent.category.LAUNCHER" />                  </intent-filter>              </activity>                </application>  




说明:

需添加的内容:android:name=".your_App_Name"

位置:当前activity所在的位置

更多相关文章

  1. Enable Geolocation in a WebView (Android)
  2. android 使内容铺满全屏
  3. Android通过PopupMenu定义弹出菜单的位置
  4. android 数据库更改数据库位置【DbFlow示范】
  5. android 开发 简单的页面布局
  6. android 如何去掉状态栏和标题栏
  7. android 操作路由表
  8. Android(安卓)控件随意拖动
  9. Android(安卓)UISegmentedControl Fragment切换标签

随机推荐

  1. Android各版本市占率:果冻豆Android4.1遥
  2. Android(安卓)免安装应用
  3. 国内最全的Android市场,最全Android软件商
  4. 在Android设备上运行纯java代码
  5. Android服务注册完整过程源码分析
  6. Android(安卓)集成Chrome 浏览器内核 Cro
  7. android test 和 instrumentation
  8. Android客户端打包方案分享
  9. Android(安卓)8.0 状态栏信号显示、信号
  10. android中网络操作使用总结(http)