开发者

Android Intent data fails and intent resolution returns ActivityNotFoundException

开发者 https://www.devze.com 2023-04-13 07:05 出处:网络
[Update:] i know the problem... but need help to resolve this. The issue is the CONTENT_URI is not mapping to the mimetype vnd.android.cursor.dir/vnd.example.manager.

[Update:] i know the problem... but need help to resolve this. The issue is the CONTENT_URI is not mapping to the mimetype vnd.android.cursor.dir/vnd.example.manager.

i create the Intent with null, and in my intentfiter i have data segment. so i guess it is not matching. So when i pass null in data, everything is good and charming!!., But i need to pass the content_URI and translate it into mimeType. i have a getType but i guess it is not resolving correctly. Could someone please help me out.

[Original Post]

I'm trying to debug this section with intents in my application and i need help to proceed further.

I have the main activity and some button. On clicking the button, i would fire an intent for a different activity and upon StartActivity i get an ActivityNotFoundException.

My guess is due to the data mimeType that i have passed to the activity. My Intent filter is Below

<intent-filter>
    <action android:name="android.intent.action.INSERT" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.dir/vnd.example.manager" />
</intent-filter>

This manager is initially empty and there is no table on the first launch of the a开发者_开发知识库ctivity.

In my Caller activity's onCreate() i do the following

Caller Activity - First entry point for the app

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.dashboard);       
    someButton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            Intent spawnEmptyIntent = new Intent(Intent.ACTION_INSERT, getIntent().getData());

            if(getIntent().getData() == null) {
                getIntent().setData(ManagerTableDefaults.CONTENT_URI);
            }

            Log.w(TAG, "Intent data string is " + getIntent().getDataString()); --- This is null for some reason!! i don't know why!!... it should have been set earlier right??
            startActivity(spawnEmptyListIntent); // New activity is not launched... Exception thrown
        }
    });

}

Error Log is

10-14 11:21:37.002: WARN/DashboardActivity(8313): Intent data string is null
10-14 11:21:37.012: INFO/ActivityManager(1643): Starting: Intent { act=android.intent.action.INSERT dat=content://com.example.android.provider.ss/manager } from pid 8313
10-14 11:21:37.022: ERROR/AndroidRuntime(8313): FATAL EXCEPTION: main
10-14 11:21:37.022: ERROR/AndroidRuntime(8313): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT dat=content://com.mvl.android.provider.nq/listmanager }


You aren't setting the data on your spawnEmptyListIntent if getIntent().getData() is null. I suspect your intent is to set the ManagerTableDefaults.CONTENT_URI as the data URI for your spawnEmptyListIntent

0

精彩评论

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

关注公众号