如何在清单中实现两个应用程序类

时间:2014-11-21 13:09:18

标签: java android android-manifest

让我们说我有一个listview作为我的主要活动。点击一个项目就会打开第二个活动。点击一个按钮就可以使用本教程中的volley库打开一个自定义列表视图(http://www.androidhive.info/2014/07/android-custom-listview-with-image-and-text-using-volley/ ) 但是,单击第二个活动中的按钮以使用齐射打开我的列表视图,我的应用程序停止。 我想到的问题始于清单,我将在下面发布。 我有两个应用程序类,因为我正在使用Parse推送通知库。但是,只有一个应用程序可以声明在清单启动时打开。所以我在这个问题(how to handle multiple application classes in android)上实现了答案。就在这之后我的应用程序在打开第三个活动时一直停止。 所以请帮助我实现这一目标。谢谢。

清单摘要



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.stevekamau.snapt"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
 
<application
    android:name="com.stevekamau.snapt.ParseApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            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>
<service android:name="com.parse.PushService" />
 
        <receiver android:name="com.parse.ParseBroadcastReceiver" >
         <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
              
            </intent-filter>
        </receiver>
    </application>

</manifest>
&#13;
&#13;
&#13;

我从这里修改了AppController类(http://www.androidhive.info/2014/07/android-custom-listview-with-image-and-text-using-volley/)以扩展ParseApplication

&#13;
&#13;
public class AppController extends ParseApplication {
	 
    public static final String TAG = AppController.class.getSimpleName();
 
    private RequestQueue mRequestQueue;
    private ImageLoader mImageLoader;
 
    private static AppController mInstance;
 
    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }
 
    public static synchronized AppController getInstance() {
        return mInstance;
    }
 
    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(getApplicationContext());
        }
 
        return mRequestQueue;
    }
 
    public ImageLoader getImageLoader() {
        getRequestQueue();
        if (mImageLoader == null) {
            mImageLoader = new ImageLoader(this.mRequestQueue,
                    new LruBitmapCache());
        }
        return this.mImageLoader;
    }
 
    public <T> void addToRequestQueue(Request<T> req, String tag) {
        // set the default tag if tag is empty
        req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
        getRequestQueue().add(req);
    }
 
    public <T> void addToRequestQueue(Request<T> req) {
        req.setTag(TAG);
        getRequestQueue().add(req);
    }
 
    public void cancelPendingRequests(Object tag) {
        if (mRequestQueue != null) {
            mRequestQueue.cancelAll(tag);
        }
    }
}
&#13;
&#13;
&#13;

如果您需要更多代码,请告诉我们。

log cat:
11-21 16:20:29.916: E/Trace(26640): error opening trace file: No such file or directory (2)
11-21 16:20:29.936: W/dalvikvm(26640): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
11-21 16:20:30.046: W/System.err(26640): Invalid int: ""
11-21 16:20:30.386: I/Adreno200-EGL(26640): <qeglDrvAPI_eglInitialize:299>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB_REL_2.0.3.04.01.01.21.010_msm8625_JB_REL_2.0.3_Merge_release_AU (Merge)
11-21 16:20:30.386: I/Adreno200-EGL(26640): Build Date: 10/26/12 Fri
11-21 16:20:30.386: I/Adreno200-EGL(26640): Local Branch: 
11-21 16:20:30.386: I/Adreno200-EGL(26640): Remote Branch: quic/jb_rel_2.0.3
11-21 16:20:30.386: I/Adreno200-EGL(26640): Local Patches: NONE
11-21 16:20:30.386: I/Adreno200-EGL(26640): Reconstruct Branch: AU_LINUX_ANDROID_JB_REL_2.0.3.04.01.01.21.010 +  NOTHING
11-21 16:20:37.636: W/dalvikvm(26640): threadid=1: thread exiting with uncaught exception (group=0x40e08438)
11-21 16:20:49.016: E/Trace(26711): error opening trace file: No such file or directory (2)
11-21 16:20:49.036: W/dalvikvm(26711): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
11-21 16:20:49.096: W/System.err(26711): Invalid int: ""

0 个答案:

没有答案