을 눌러 전화번호:내가 원하는 내용에 있어 응용 프로그램 선택
-
21-12-2019 - |
문제
그것은 같은 문제에 안드로이드 사이얼에 눌러 전화 번호 링크.았다 everthings 으로 밝혔다.
내용에서 나타나 응용 프로그램을 선택할 때,전화번호를 탭합니다.
나
package com.example.editcall;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class OutgoingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.d(OutgoingCallReceiver.class.getSimpleName(), intent.toString() + ", call to: " + phoneNumber);
Toast.makeText(context, "Outgoing call catched: " + phoneNumber, Toast.LENGTH_LONG).show();
}
}
고서 AndroidManifest.xml:
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<receiver
android:name=".OutgoingCallReceiver"
android:exported="true" >
<intent-filter android:priority="100" >
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tel" />
</intent-filter>
</receiver>
하지만 그것은 표시되지 않는 응용 프로그램에서 선택.어떤 생각이 있으십니까?
솔루션:
로@CommonsWare 아래에 언급 할 필요가 있는 활동입니다.
또한, android.intent.category.LAUNCHER
작동하지 않을해야합니다, android.intent.category.DEFAULT
.
잊을 수 있습니다(이에 대한:-)에 대 android:priority
고 android:exported
.
그래서,이동:
<activity android:name=".ui.SearchActivity" >
<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>
</activity>
이 얻을 전화번호:
public class SearchActivity extends FragmentActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String calledNumber = null;
String inputURI = this.getIntent().getDataString();
if (inputURI != null) {
Uri uri = Uri.parse(Uri.decode(inputURI));
if (uri.getScheme().equals("tel")) {
calledNumber = uri.getSchemeSpecificPart();
}
}
}
해결책
귀하의 <intent-filter>
위해 설계되었는 <activity>
.당신 행운을 사용하여 그와 함께 <receiver>
.또한,선택만을 보여줍 활동입니다.따라서,만들기 <activity>
, 고,사용 <intent-filter>
이있는(아마도 뺀 priority
).
제휴하지 않습니다 StackOverflow