我想我的登记活动,以便它可以通过活动选择器/选择器一起使用,允许用户选择是否要选择我的应用程序/活动来完成他们正在尝试做的。

我要为用户提供选项,以便能够选择我的应用程序时,他们要发送短信,当他们想要放置的呼出,要尽量做到这一点,我添加中的以下的代码段在我的清单我的活动标记:

<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

然而活动选择器永远不会出现和不提供选择给用户使用的本机应用程序。任何人都可以看到我在哪里我的问题呢?

修改

我已想出我需要添加

<data android:scheme="sms" />
<data android:scheme="smsto" />

该SMS消息,但我使用的呼出什么?

修改2:

我曾尝试用于呼出呼叫的情况如下:

 <intent-filter>
 <action android:name="android.intent.action.VIEW" />
 <action android:name="android.intent.action.DIAL" />
 <category android:name="android.intent.category.DEFAULT" />
 <category android:name="android.intent.category.BROWSABLE" />
 <data android:scheme="tel" />
 </intent-filter>

但同样没有运气,这已经从1.6封锁?

修改3:

这是发生了什么,当我点击文本手机:

“替代文字”

所以我想,当我点击呼叫一回事移动

有帮助吗?

解决方案

我觉得它应该帮助你。

<intent-filter >
    <action android:name="android.intent.action.CALL_PRIVILEGED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="tel" />
</intent-filter>

测试在Android 2.1

其他提示

这是因为活动和服务,可以根据自己的不皮卡之外的意图。你需要使用一个BroadcastReceiver。为了实现这一点,执行以下操作:

扩展Android的广播接收器类,如下所示:

public class MyReceiver extends BroadcastReceiver {

 @Override
 public void onReceive(Context context, Intent intent) {
        Context context = getApplicationContext();
  Intent sendIntent = new Intent();
  if ( intent.getAction().equals(Intent.NEW_OUTGOING_CALL) ) {
   sendIntent.setClass(context, MyActivity.class);
   context.startActivity(sendIntent);
  }
        else if ( intent.getAction().equals(Intent.SOME_OTHER_INTENT) {
            sendIntent.setClass(context, MyService.class);
   context.startService(sendIntent);
        }
        // More else ifs for more intents you want to catch.
 }

}

然后,你需要声明的接收器在您的清单如下:

<receiver android:name="MyReceiver">
  <intent-filter>
    <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        // more intents you want to catch here
  </intent-filter>
</receiver>

只有意图在清单将被接收机捕获声明,所以如果你想赶上由系统或其他程序抛出几个意图和想做的事时,他们的意图被发现在此指定那些意图完全一样的东西清单并跳过如果/ else块中的onReceive方法。

这为我工作

   <activity
        android:label="@string/app_name"
        android:name=".TestIntentActivity" >            
      <intent-filter> 
         <action android:name="android.intent.action.CALL" />
         <category android:name="android.intent.category.DEFAULT" />
         <action android:name="android.intent.action.CALL_PRIVILEGED" />
         <data android:scheme="tel" />
      </intent-filter>
    </activity>

您需要优先增加意图过滤器,这样的Android需要考虑它。例如:

 <activity android:name="YourActivity">
   <intent-filter android:priority="100">
      <action android:name="android.intent.action.CALL_PRIVILEGED" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:mimeType="text/plain" />
   </intent-filter>
 </activity>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top