android Intent 使用 小记

 

1 : A.apk activity 访问B.apk 的activity

 

在B.apk中AndroidManifest.xml中定义

 

        <activity
            android:name=".activity.MessageCompose"
            android:label="@string/app_name"
            android:enabled="false" >
           
             <intent-filter android:label="@string/app_name">
                     <action android:name="android.intent.action.SEND " />
                     <data android:mimeType="*/*" />
                     <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

        </activity>

 

A.apk 访问 B.apk 的MessageCompose.activity:

 

        Intent send = new Intent(Intent.ACTION_SEND );
        send.setType("text/plain");
        send.putExtra(Intent.EXTRA_TEXT, url);
        send.putExtra(Intent.EXTRA_SUBJECT, title);
        send.putExtra(Browser.EXTRA_SHARE_FAVICON, favicon);
        send.putExtra(Browser.EXTRA_SHARE_SCREENSHOT, screenshot);
        try {
            c.startActivity(Intent.createChooser(send, c.getString(
                    R.string.choosertitle_sharevia)));
        } catch(android.content.ActivityNotFoundException ex) {
            // if no app handles it, do nothing
        }

 

 

 

 

        使用:setComponent

         //-----核心部分----- 前名一个参数是应用程序的包名,后一个是这个应用程序的主Activity名

                Intent intent=new Intent();      
                intent.setComponent(new ComponentName("com.droidnova.android.games.vortex",      
                                                     "com.droidnova.android.games.vortex.Vortex"));      
                startActivity(intent);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值