6

I have a problem regarding my intent. It seems that my app crashes when i select the intent. I found the line of error code due to the stack trace. But i couldn't find anything wrong with it. Hope anyone can help me with this.

This is the java code in line 121:
startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData()));

This is the stack trace:

11-24 16:09:24.634: ERROR/AndroidRuntime(222): Uncaught handler: thread main exiting due to uncaught exception
11-24 16:09:24.834: ERROR/AndroidRuntime(222): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT dat=content://joel.google.provider.TemplatePad/templates }
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.app.Activity.startActivityForResult(Activity.java:2749)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.app.Activity.startActivity(Activity.java:2855)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at joel.AndroidGroupSMS.TemplatesList.onOptionsItemSelected(TemplatesList.java:121)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.app.Activity.onMenuItemSelected(Activity.java:2170)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:525)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.view.View.onTouchEvent(View.java:4179)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.widget.TextView.onTouchEvent(TextView.java:6541)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.view.View.dispatchTouchEvent(View.java:3709)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.os.Looper.loop(Looper.java:123)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at android.app.ActivityThread.main(ActivityThread.java:4363)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at java.lang.reflect.Method.invokeNative(Native Method)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at java.lang.reflect.Method.invoke(Method.java:521)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-24 16:09:24.834: ERROR/AndroidRuntime(222):     at dalvik.system.NativeStart.main(Native Method)
Yoni Samlan
  • 37,905
  • 5
  • 60
  • 62
Joel Seah
  • 674
  • 3
  • 13
  • 34

2 Answers2

1

Can you show us the intent filter you're hoping to match with your implicit intent there? This part:

act=android.intent.action.INSERT dat=content://joel.google.provider.TemplatePad/templates

means you need to have an activity with an intent filter set up to handle implicit requests for the INSERT action on content://joel.google.provider.TemplatePad-schemed URIs.

Yoni Samlan
  • 37,905
  • 5
  • 60
  • 62
  • Should be the entire comment above that you're talking about. – Joel Seah Nov 25 '10 at 05:13
  • Are you sure you want a MIME type for picking a vnd.google.note? That looks copied and pasted from Google's notepad example. Additionally, what's the Content Provider manifest element you're using to match that `content://joel.google.provider.TemplatePad/templates` URI? – Yoni Samlan Nov 25 '10 at 20:55
  • Yes this is from the Google's notepad example. And I have no idea what content provider you're talking about. Sorry, but I'm a newbie to Android programming. – Joel Seah Nov 26 '10 at 05:10
  • You should definitely read up on Content Providers; the intent you're trying to match is a content-provider insert action (http://developer.android.com/guide/topics/providers/content-providers.html). Also, do you actually know what you're starting the intent for? It looks like you're just forwarding the Insert intent from the activity you're trying to invoke from (getIntent().getData()). What are you *actually* trying to accomplish here? – Yoni Samlan Nov 26 '10 at 16:52
  • I'm trying to insert data. That's all. It previously worked in the sample code. But once i finished transferring the codes into another project, the Intent would fail. All due to the insert thingy. So currently I'm stuck. Only able to develop on the sammple codes. – Joel Seah Nov 27 '10 at 09:05
  • The whole point of the Notepad sample you cloned is to illustrate usage for ContentProviders, really; if you're not grokking what those are about after reading the sample and the docs I linked to you probably don't need a ContentProvider in the first place and should just be mushing your data around internally with SQLite or a basic ORM built on it in a much simpler way rather than just pasting Google's code. Content providers are meant for data you want to expose to third-party applications and add a level of complexity most devs don't need. – Yoni Samlan Nov 29 '10 at 19:06
  • I see. So what you mean is that I don't need a Content Provider in my project since they are used to share data among the applications. Which means I can only play with the SQLlite database. Correct? – Joel Seah Dec 01 '10 at 06:37
  • But if removing my Content Provider, how am I going to retrieve the data from the database and place it somewhere else? – Joel Seah Dec 01 '10 at 06:52
  • 1
    Just write the SQLite (or call a common class in your app that makes the SQLite calls, or use an ORM (http://stackoverflow.com/questions/371538/any-good-orm-tools-for-android-development)). Otherwise, you'll be writing all your data requests in content-provider syntax, running those through Intents to a ContentProvider, then in turn running those back down into SQLite. The only reason to muck about with ContentProviders is if you want to give 3rd-party apps access to your data. They're a great feature for that, but they just aren't needed for 95%+ of appps. – Yoni Samlan Dec 01 '10 at 16:15
  • Yoni, do you mind taking a look at my latest question? Its after i created the sqlite database (http://stackoverflow.com/questions/4333110/error-with-inserting-data-into-sqlite-database) – Joel Seah Dec 02 '10 at 08:40
  • I think i solved the error. I have two intent filters. So i thought of trying to combine the 2 intent filters into one intent filter. And it works. RESOLVED. – Joel Seah Dec 09 '10 at 06:31
  • 1
    Great - glad to hear it. I'd appreciate it if you'd mark my answer as accepted if you found it helpful in solving your problem. – Yoni Samlan Dec 09 '10 at 07:42
  • @JoelSeah I am struggling with implicit intent filters too. Can you edit your questions with what you had, and add a comment with what works. Thanks in advance! – rds Feb 22 '12 at 18:43
  • @YoniSamlan this is the wisest piece of advice I have read since I got bogged down trying to reuse the Notepad sample a week ago: "Otherwise, you'll be writing all your data requests in content-provider syntax, running those through Intents to a ContentProvider, then in turn running those back down into SQLite." – likejudo May 28 '14 at 00:23
0

Have you added the Activity to your manifest?

Also your call to StartActivity() looks off. Here is how I am familiar with launching a new Activity

Intent i = new Intent(this, NextActivity.class);
startActivity(i);

Edit: It's come to my attention you likely were not having difficulty with Explicitly launching an Activity. Sorry!

Thomas
  • 3,603
  • 1
  • 18
  • 23
  • I was having the same problem – Albinoswordfish Nov 24 '10 at 16:53
  • 1
    Your example is an explicit intent ("start activity X." He's creating an implicit intent ("Start an activity to handle this bunch of data."). They're not interchangeable, assuming what he actually wants to do is set up some bit of code to handle internal or external requests for specific kinds of data. – Yoni Samlan Nov 24 '10 at 16:54
  • Ah, my mistake. I haven't had to work with Implicit Intents yet. I should do some research on them to see if they fit some of my current needs. – Thomas Nov 24 '10 at 16:55