说明一下此问题的背景,我在做的项目需要一个全局变量以在多个Activity之间记录路径,根据网上查到的解决方案,我写了这样一个类来作为全局变量使用import android.app.Application;public class Filepath extends Application {
private String filepath;
public String getFilepath(){
return filepath;
}
public void setFilepath(String filepath){
this.filepath=filepath;
}
}
网上说需要将这个类在manifest里申明一下,但没有提供例子,请教大牛声明方法,谢谢
在线坐等

解决方案 »

  1.   

    <application 
     android:name=".Filepath"
     ...
    >给分吧
      

  2.   

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.pro"
          android:versionCode="1"
          android:versionName="1.0">
        <application
         android:icon="@drawable/icon" 
         android:label="@string/app_name"
         android:debuggable="true"
         android:name=".globe.Filepath">
            <activity android:name=".Test"
                      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>
    </manifest> 
    假如你该类的包名是com.pro.globe.Filepath
    那么按上面代码红色标出的地方设置下就可以了。