There seems to be two problems that I am having trouble with. The first case is when I launch the clock app and works perfectly, this seems to be the case when I launch most apps.
The second case is when I try to launch an activity such as the Phone activity. When I go to get the Intent, getLaunchIntentForPackage(app.pname) returns null. Is there a different way to get the Intent of the phone activity so that I can launch it in this case?
The third case is when I go to launch an activity such as the Camera activity. It seems that I have to have the Camera activity already within my androidManifest.xml file to launch it but is there another way to go around this? My app has the capibility to launch any app from its UI so I cannot add every single activity an android device has into my manifest file beforehand. Thank you!
Java:
Intent launchApp = getPackageManager().getLaunchIntentForPackage(app.pname);
System.out.println(Intent of " + appName + ": + " " +launchApp);
if(launchApp!=null){
System.out.println("Permission granted to launch " + appName);
startActivity( launchApp );
}
else{
System.out.println("Permission not granted to launch " + appName);
}
Logcat:
08-07 09:38:57.031: I/System.out(1056): Intent of Clock: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.htc.android.worldclock/.WorldClockTabControl }
08-07 09:38:57.041: I/System.out(1056): Permission granted to launch Clock
08-07 09:38:59.783: I/System.out(1056): Intent of Phone: null
08-07 09:38:59.783: I/System.out(1056): Permission not granted to launch Phone
08-07 09:39:10.564: I/System.out(1056): Intent of Camera: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.camera/com.android.internal.app.ResolverActivity }
08-07 09:39:10.574: I/System.out(1056): Permission granted to launch Camera
08-07 09:39:10.574: D/AndroidRuntime(1056): Shutting down VM
08-07 09:39:10.574: W/dalvikvm(1056): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
08-07 09:39:10.614: E/AndroidRuntime(1056): FATAL EXCEPTION: main
08-07 09:39:10.614: E/AndroidRuntime(1056): java.lang.IllegalStateException: Could not execute method of the activity
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.view.View$1.onClick(View.java:2191)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.view.View.performClick(View.java:2532)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.view.View$PerformClick.run(View.java:9293)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.os.Handler.handleCallback(Handler.java:587)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.os.Looper.loop(Looper.java:150)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.ActivityThread.main(ActivityThread.java:4306)
08-07 09:39:10.614: E/AndroidRuntime(1056): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 09:39:10.614: E/AndroidRuntime(1056): at java.lang.reflect.Method.invoke(Method.java:507)
08-07 09:39:10.614: E/AndroidRuntime(1056): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-07 09:39:10.614: E/AndroidRuntime(1056): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-07 09:39:10.614: E/AndroidRuntime(1056): at dalvik.system.NativeStart.main(Native Method)
08-07 09:39:10.614: E/AndroidRuntime(1056): Caused by: java.lang.reflect.InvocationTargetException
08-07 09:39:10.614: E/AndroidRuntime(1056): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 09:39:10.614: E/AndroidRuntime(1056): at java.lang.reflect.Method.invoke(Method.java:507)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.view.View$1.onClick(View.java:2186)
08-07 09:39:10.614: E/AndroidRuntime(1056): ... 11 more
08-07 09:39:10.614: E/AndroidRuntime(1056): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.camera/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1565)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1539)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.Activity.startActivityForResult(Activity.java:2919)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.Activity.startActivity(Activity.java:3025)
08-07 09:39:10.614: E/AndroidRuntime(1056): at com.worklight.androidnativeapp.AndroidNativeApp.appClicked(AndroidNativeApp.java:284)
08-07 09:39:10.614: E/AndroidRuntime(1056): ... 14 more
How to launch the camera
How to launch the dialer
to launch a specific app you need to know the package name and the class name
try{
Intent i = new Intent();
i.setClassName("com.example.app", "com.example.app.MainActivity");
i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(e);
}catch(ActivityNotFoundException e){
e.printStackTrace();
}
Related
I am trying to get my android app invoke HP ePrint PDF Preview Activity.
Intent intent = new Intent ();
intent.setPackage("com.hp.android.print");
intent.setClassName("com.hp.android.print", "com.hp.android.print.preview.PdfPreviewActivity");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.parse("http://www.pdf995.com/samples/pdf.pdf");
intent.setDataAndType( uri, "application/pdf" );
if (intent.resolveActivity(getPackageManager()) != null)
{
getBaseContext().startActivity(intent);
}
I am getting the below error (taken from Logcat of the device):
2014-03-13 03:02:20.915 D 11119/AndroidRuntime: Shutting down VM
2014-03-13 03:02:20.915 W 11119/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40a491f8)
2014-03-13 03:02:20.925 E 11119/AndroidRuntime: FATAL EXCEPTION: main
**java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hp.android.print/com.hp.android.print.preview.PdfPreviewActivity}:** java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
**Caused by: java.lang.NullPointerException
at com.hp.android.print.utils.UriUtils.normalizeIntent(UriUtils.java:133)**
at com.hp.android.print.preview.PdfPreviewActivity.onContinueCreate(PdfPreviewActivity.java:123)
at com.hp.android.print.preview.PrintPreview.handleExternalReceivedIntent(PrintPreview.java:261)
at com.hp.android.print.preview.PrintPreview.onCreate(PrintPreview.java:181)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
... 11 more
2014-03-13 03:02:20.935 W 132/ActivityManager: Force finishing activity com.hp.android.print/.preview.PdfPreviewActivity
2014-03-13 03:02:20.955 W 132/ActivityManager: Force finishing activity com.example.droidprinttest/.MainActivity
HP ePrint works fine when used manually. Any idea about a fix?
[EDIT] My Goal is to get a PDF file printed on the fly, a solution without preview is okay for me too.
I have an autocompletetextview. I want a method to run "onClick". Here is my XML:
<AutoCompleteTextView
android:id="#+id/GivenByBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="setupMiranda"
android:gravity="left"
/>
When this is run, I get errors. It doesn't matter what onClick is set to, it will always cause an error. If I remove the android:onclick line everything works fine, but that is not what I want.
Here is an excerpt from logCat:
08-07 13:56:36.040: E/AndroidRuntime(32735): FATAL EXCEPTION: main
08-07 13:56:36.040: E/AndroidRuntime(32735): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.itsmr.dre_android_clean/com.itsmr.dre_android_clean.MainActivity}: android.view.InflateException: Binary XML file line #46: Error inflating class <unknown>
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.access$700(ActivityThread.java:140)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.os.Looper.loop(Looper.java:137)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.main(ActivityThread.java:4921)
08-07 13:56:36.040: E/AndroidRuntime(32735): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
08-07 13:56:36.040: E/AndroidRuntime(32735): at dalvik.system.NativeStart.main(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: android.view.InflateException: Binary XML file line #46: Error inflating class <unknown>
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.Activity.setContentView(Activity.java:1924)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.itsmr.dre_android_clean.MainActivity.onCreate(MainActivity.java:81)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.Activity.performCreate(Activity.java:5188)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
08-07 13:56:36.040: E/AndroidRuntime(32735): ... 11 more
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: java.lang.reflect.InvocationTargetException
08-07 13:56:36.040: E/AndroidRuntime(32735): at java.lang.reflect.Constructor.constructNative(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-07 13:56:36.040: E/AndroidRuntime(32735): ... 26 more
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: java.lang.NullPointerException
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.AutoCompleteTextView$PassThroughClickListener.access$302(AutoCompleteTextView.java:1226)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.AutoCompleteTextView.setOnClickListener(AutoCompleteTextView.java:200)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.View.<init>(View.java:3678)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.TextView.<init>(TextView.java:574)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.EditText.<init>(EditText.java:76)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.AutoCompleteTextView.<init>(AutoCompleteTextView.java:137)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.AutoCompleteTextView.<init>(AutoCompleteTextView.java:133)
08-07 13:56:36.040: E/AndroidRuntime(32735): ... 29 more
I get this error no matter what function is set onClick. Even a function with an empty body causes this error.
What is causing this error?
Getting run time exception as "inflating class fragment" when I tried to add Google map in my android application. I go through all the previous comments similar to which I have posted. But I couldn't solve it.
Log file is attached here
08-07 05:30:41.587: E/AndroidRuntime(2574): FATAL EXCEPTION: main
08-07 05:30:41.587: E/AndroidRuntime(2574): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newapp/com.example.newapp.NewApp}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.os.Looper.loop(Looper.java:137)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.reflect.Method.invoke(Method.java:525)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-07 05:30:41.587: E/AndroidRuntime(2574): at dalvik.system.NativeStart.main(Native Method)
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Activity.setContentView(Activity.java:1895)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.example.newapp.NewApp.onCreate(NewApp.java:12)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Activity.performCreate(Activity.java:5133)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 11 more
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 21 more
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.example.newapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.newapp-1, /vendor/lib, /system/lib]]
08-07 05:30:41.587: E/AndroidRuntime(2574): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 24 more
08-07 05:30:47.677: I/Process(2574): Sending signal. PID: 2574 SIG: 9
08-07 05:30:53.767: D/AndroidRuntime(2650): Shutting down VM
08-07 05:30:53.767: W/dalvikvm(2650): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
08-07 05:30:53.857: E/AndroidRuntime(2650): FATAL EXCEPTION: main
08-07 05:30:53.857: E/AndroidRuntime(2650): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newapp/com.example.newapp.NewApp}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.os.Looper.loop(Looper.java:137)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.reflect.Method.invoke(Method.java:525)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-07 05:30:53.857: E/AndroidRuntime(2650): at dalvik.system.NativeStart.main(Native Method)
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Activity.setContentView(Activity.java:1895)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.example.newapp.NewApp.onCreate(NewApp.java:12)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Activity.performCreate(Activity.java:5133)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 11 more
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 21 more
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.example.newapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.newapp-1, /vendor/lib, /system/lib]]
08-07 05:30:53.857: E/AndroidRuntime(2650): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 24 more
08-07 05:30:56.837: I/Process(2650): Sending signal. PID: 2650 SIG: 9
manifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="********************************" />
<permission
android:name="com.venky.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.newapp.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.newapp.NewApp"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and the java file NewApp.java
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class NewApp extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_app);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.new_app, menu);
return true;
}
}
activity_new_app.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".NewApp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Please help me to solve this problem.
One visible mistake
https://developers.google.com/maps/documentation/android/start
Your meta tag must be a child of application tag in manifest
<meta-data // should be inside application tag.
android:name="com.google.android.maps.v2.API_KEY"
android:value="********************************" />
Change this
<permission
android:name="com.venky.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
to
<permission
android:name="com.example.newapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
I'm trying to open a web browser from my app using:
Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse("http://developer.android.com/"));
startActivity(browser);
But the app just crashes:
08-07 17:18:29.912: E/AndroidRuntime(751): FATAL EXCEPTION: main
08-07 17:18:29.912: E/AndroidRuntime(751): java.lang.NullPointerException
08-07 17:18:29.912: E/AndroidRuntime(751): at android.app.Activity.startActivityForResult(Activity.java:3131)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.app.Activity.startActivity(Activity.java:3237)
08-07 17:18:29.912: E/AndroidRuntime(751): at com.Co.DrumKit$9.onClick(DrumKit.java:658)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.view.View.performClick(View.java:3110)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.view.View$PerformClick.run(View.java:11934)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.os.Handler.handleCallback(Handler.java:587)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.os.Looper.loop(Looper.java:132)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.app.ActivityThread.main(ActivityThread.java:4123)
08-07 17:18:29.912: E/AndroidRuntime(751): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 17:18:29.912: E/AndroidRuntime(751): at java.lang.reflect.Method.invoke(Method.java:491)
08-07 17:18:29.912: E/AndroidRuntime(751): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
08-07 17:18:29.912: E/AndroidRuntime(751): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-07 17:18:29.912: E/AndroidRuntime(751): at dalvik.system.NativeStart.main(Native Method)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I write a simple programm, but there is problem.
Here is the code:
package player.org;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
public class Player extends Activity {
/** Called when the activity is first created. */
private MediaPlayer media;
private ProgressBar progress;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
progress=(ProgressBar) findViewById(R.id.progress);
progress.setVisibility(ProgressBar.INVISIBLE);
And here is the tabs.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#FFFFFF">
<ProgressBar
android:id="#+id/progress"
android:layout_width="250dp"
android:layout_height="8dp"
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_x="35dp"
android:layout_y="320dp"/>
</AbsoluteLayout>
But when I run program, it's force closed because of Null pointer exception. Can anyone help?
Here is the LogCat:
08-07 08:24:02.516: ERROR/AndroidRuntime(334): FATAL EXCEPTION: main
08-07 08:24:02.516: ERROR/AndroidRuntime(334): java.lang.RuntimeException: Unable to start activity ComponentInfo{player.org/player.org.Player}: java.lang.NullPointerException
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.os.Looper.loop(Looper.java:123)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at java.lang.reflect.Method.invoke(Method.java:507)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at dalvik.system.NativeStart.main(Native Method)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): Caused by: java.lang.NullPointerException
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at player.org.Player.onCreate(Player.java:26)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-07 08:24:02.516: ERROR/AndroidRuntime(334): ... 11 more
08-07 08:24:02.536: WARN/ActivityManager(67): Force finishing activity player.org/.Player
08-07 08:24:03.056: WARN/ActivityManager(67): Activity pause timeout for HistoryRecord{4054b008 player.org/.Player}
08-07 08:24:03.167: INFO/ActivityManager(67): Displayed com.android.launcher/com.android.launcher2.Launcher: +37s552ms
08-07 08:24:13.233: WARN/ActivityManager(67): Activity destroy timeout for HistoryRecord{4054b008 player.org/.Player}