开发者

how to install two application with one installation?

开发者 https://www.devze.com 2023-04-12 23:31 出处:网络
i am new to android application.I have created two sample applications as Oneproject,Twoproject.when i run the Oneproject then the Twoproject automatically should be install in the same device,For thi

i am new to android application.I have created two sample applications as Oneproject,Twoproject.when i run the Oneproject then the Twoproject automatically should be install in the same device,For this i have intialize intent filter in androidmanifestfile.xml as follows:

<?xml version="1.0" encoding="utf-8"?>

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".OneAppActivity"
              android:label="@string/app_name">
        <intent-filter>

        </intent-filter>
    </activity>

   <activity android:name="com.twoproject.two.TwoAppActivity"
              android:label="twoapp">
        <intent-filter>
           <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

I can install开发者_如何转开发 the two application into my device but when i launch the Oneproject then i am not able to lanuch the Twoproject.how can i install two applications(apks)with single installation and launch?

any body plzzz help me......


In eclipse right click on OneProject>Properties>java Build Path> In right window click Project>Add>TwoProject>OK>OK

Thats it!!! When u install OneProject TwoProject will get installed. Console will show found dependency.

cheers!!

Remove this from Oneproject:

      <activity android:name="com.twoproject.two.TwoAppActivity" 
     android:label="twoapp"> 
         <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
       </intent-filter> 
      </activity> 

Add this tags to the intent filter of OneProject:

     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 

Both the applications get installed, I guarantee!!!


add this to your activity tag:

<intent-filter>
   <action android:name="android.intent.action.MAIN" />
   <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

now you manifest code will look like:

<?xml version="1.0" encoding="utf-8"?>

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".OneAppActivity"
              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="com.twoproject.two.TwoAppActivity"
              android:label="twoapp">
        <intent-filter>
           <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Now it will create two launcher icon on your device.That's what you are asking?


I don't believe you can, as the Android concept of an 'application' (as in the <application> element in the XML file) is pretty much tied to a single .apk file.

However, you can achieve the same effect but simply copying all the activities from TwoProject into OneProject. A single application can have multiple launcher icons so from the user's perspective it'll still look like two runnable things on the launcher. Plus, this way you get to share code and resources. Does that suffice?

0

精彩评论

暂无评论...
验证码 换一张
取 消