开发者

intent-filter not working

开发者 https://www.devze.com 2023-01-07 04:42 出处:网络
One of the activities in my app has an intent-filter with: Action - VIEW Categories - DEFAULT BROWSABLE Data - scheme is \'myapp123\'. I want to start this activity from another application using

One of the activities in my app has an intent-filter with:

  • Action - VIEW
  • Categories - DEFAULT
  • BROWSABLE

Data - scheme is 'myapp123'. I want to start this activity from another application using the Intent but I get NoActivityFoundException. Even if I type myapp123:// from the browser, it doesn't get called. Any help on resolving this issue will be appreciated.

AndroidManifest.xml

<activity android:name="TwitterStatus" android:label="TwitterStatus">
<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <DATA android:scheme="myapp123" />
</intent-filter>
</activity>

actually I have this callback address for OAuth authentication to Twitter

mTwitterCallBack = "myapp123://twittercallback" ;

after authenticating by twitter the browser itself tries to search for this URI

for the purpose of testing, I have put a test option in one of the activities as follows

Activity

Intent tstIntent = new Intent (Intent.ACTION_VIEW, Uri.parse(mTstURI)) ;  
// value of mTstURI entered at runtime - myapp123://twittercallback
try {
 startActivity(tstIntent) ;
} 开发者_如何学编程catch (ActivityNotFoundException e) {
    e.printStackTrace();
}   

// always catches the exception.


add the host

<data android:scheme="myapp123" host="twittercallback" />

and try again


One problem I can see is with your Activity class name "TwitterStatus":

<activity android:name="TwitterStatus" android:label="TwitterStatus">

It needs to be fully qualified, or it needs to be prefixed with a ".", e.g.

<activity android:name="com.yourdomain.TwitterStatus" android:label="TwitterStatus">

or

<activity android:name=".TwitterStatus" android:label="TwitterStatus">

The Android docs for the element explain this:

android:name

The name of the class that implements the activity, a subclass of Activity. The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity"). However, as a shorthand, if the first character of the name is a period (for example, ".ExtracurricularActivity"), it is appended to the package name specified in the element.

There is no default. The name must be specified.

0

精彩评论

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