Android 单击按钮时如何启动清单中提到的第二个应用程序
如何在清单中定义的第二个应用程序AppController中启动活动单击按钮时,清单文件中会提到第二个应用程序及其活动,请提供单击按钮启动活动的代码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"
<?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);
}
});
}