I started with a notepad example on an Android website. What I did was add another table to the database and make it available in the class NotePad(another inner class with a name Tablethat expanded has been added BaseColumns). It seems that the database is reading correctly, and I can start my scan directly. However, when I try to launch it in the same way that google launches NoteEditor(through intent ACTION_INSERT), the application crashes.
I have an updated URI for the new table, and the intent filter for the activity I want to run is in the manifest (with the corresponding mimetype type). However, it seems that he will not be able to find and launch the activity that I want.
Here is the corresponding result:
02-04 01:13:54.964: DEBUG/AndroidRuntime(342): Shutting down VM
02-04 01:13:54.964: WARN/dalvikvm(342): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): FATAL EXCEPTION: main
**02-04 01:13:54.984: ERROR/AndroidRuntime(342): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT dat=content://com.google.provider.NotePad/courses }**
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.app.Activity.startActivityForResult(Activity.java:2827)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.app.Activity.startActivity(Activity.java:2933)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at com.example.android.notepad.CoursesList.onOptionsItemSelected(CoursesList.java:154)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.app.Activity.onMenuItemSelected(Activity.java:2205)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:748)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.view.View$PerformClick.run(View.java:9080)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.os.Handler.handleCallback(Handler.java:587)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.os.Handler.dispatchMessage(Handler.java:92)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.os.Looper.loop(Looper.java:123)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at android.app.ActivityThread.main(ActivityThread.java:3647)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at java.lang.reflect.Method.invoke(Method.java:507)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-04 01:13:54.984: ERROR/AndroidRuntime(342): at dalvik.system.NativeStart.main(Native Method)
02-04 01:13:55.014: WARN/ActivityManager(61): Force finishing activity com.example.android.notepad/.CoursesList
:
<activity android:name="AddCourseView"
android:theme="@android:style/Theme.Light"
android:label="@string/title_note"
android:screenOrientation="sensor"
android:configChanges="keyboardHidden|orientation"
>
<intent-filter android:label="@string/resolve_course_edit">
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="com.android.notepad.action.EDIT_COURSE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.course" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.INSERT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/vnd.google.course" />
</intent-filter>
</activity>
, :
Uri intentUri = getIntent().getData();
Intent intent = new Intent(Intent.ACTION_INSERT, intentUri );
startActivity( intent );
getType() NotePadProvider:
@Override
public String getType(Uri uri) {
switch (sUriMatcher.match(uri)) {
case NOTES:
case LIVE_FOLDER_NOTES:
return Notes.CONTENT_TYPE;
case NOTE_ID:
return Notes.CONTENT_ITEM_TYPE;
case COURSES:
return Courses.CONTENT_TYPE;
case COURSE_ID:
return Courses.CONTENT_ITEM_TYPE;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
}
:
NotePad { public static final AUTHORITY = "com.google.provider.NotePad";
private NotePad() {}
public static final class Notes implements BaseColumns {
private Notes() {}
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/notes");
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.note";
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.google.note";
public static final String DEFAULT_SORT_ORDER = "modified DESC";
public static final String TITLE = "title";
public static final String NOTE = "note";
public static final String TASK_DESCRIPTION = "description";
public static final String TASK_LOCATION = "location";
public static final String TASK_START_TIME = "starttime";
public static final String TASK_END_TIME = "endtime";
public static final String CREATED_DATE = "created";
public static final String MODIFIED_DATE = "modified";
public static final String WEIGHT = "weight";
public static final String RELATED_COURSE = "relatedcourse";
}
public static final class Courses implements BaseColumns {
private Courses() {}
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/courses");
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.course";
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.google.course";
public static final String DEFAULT_SORT_ORDER = "modified DESC";
public static final String TITLE = "title";
public static final String PROFESSOR = "professor";
public static final String DESCRIPTION = "description";
public static final String CREATED_DATE = "created";
public static final String MODIFIED_DATE = "modified";
}
}
:
<provider android:name="NotePadProvider"
android:authorities="com.google.provider.NotePad"/>
ok, :
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(Courses.CONTENT_TYPE);
startActivity(intent);
. :
02-06 22: 48: 26.076: ERROR/AndroidRuntime (640): java.lang.RuntimeException: Activity ComponentInfo {com.example.android.notepad/com.example.android.notepad.AddCourseView}: java.lang.NullPointerException