Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 单击按钮时如何启动清单中提到的第二个应用程序_Android - Fatal编程技术网

Android 单击按钮时如何启动清单中提到的第二个应用程序

Android 单击按钮时如何启动清单中提到的第二个应用程序,android,Android,如何在清单中定义的第二个应用程序AppController中启动活动单击按钮时,清单文件中会提到第二个应用程序及其活动,请提供单击按钮启动活动的代码 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="kashif.gulzar" android:versionCode="1"

如何在清单中定义的第二个应用程序AppController中启动活动单击按钮时,清单文件中会提到第二个应用程序及其活动,请提供单击按钮启动活动的代码

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

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/shopping"
        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 android:name=".ListViewDemo"/>
    </application>
    <application 
        android:name="kashif.gulzar.app.AppController"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="kashif.gulzar.app.OfferActivity"
            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>
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

请提供代码

首先,您应该只使用一个标签:


Android此时不使用多个元素。
<application ...>
 <activity .../> 
 <activity .../>
 <activity .../>
</application>
Button button = (Button) view.findViewById(R.id.button1);
        if(button != null) 
        {
            button.setOnClickListener(new OnClickListener() 
            {
                @Override
                public void onClick(View v) 
                {
                    Intent intent = new Intent(MainActivity.this, OfferActivity.class);
                    startActivity(intent);
                }
            });
         }