google maps - how to make button start new activity containing android googlemap -
i have created class display google map want make class start first when press class button go googlemap class app crashing when press button code of new class
import android.content.intent; import android.os.bundle; import android.view.view; public class homepage extends mainactivity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.layout1); } public void onclick(view view) { startactivity(new intent("com.example.gmapsapp.mainactivity")); } public void onclick1(view view) { startactivity(new intent("com.example.gmapsapp.homepage2")); } }
this mainactivity contain map
public class mainactivity extends fragmentactivity { private static final int gps_errordialog_request = 9001; googlemap mmap; private static final double nasrcity_lat = 30.066108, nasrcity_lng =31.336184; private static final float defaultzoom = 13; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if (servicesok()) { setcontentview(r.layout.activity_map); if (initmap()) { toast.maketext(this, "ready map!", toast.length_short).show(); gotolocation(nasrcity_lat, nasrcity_lng, defaultzoom); } else { toast.maketext(this, "map not available!", toast.length_short).show(); } } else { setcontentview(r.layout.activity_main); } }
the logcat
03-28 12:40:22.260: e/androidruntime(2579): fatal exception: main 03-28 12:40:22.260: e/androidruntime(2579): process: com.example.gmapsapp, pid: 2579 03-28 12:40:22.260: e/androidruntime(2579): java.lang.illegalstateexception: not execute method of activity 03-28 12:40:22.260: e/androidruntime(2579): @ android.view.view$1.onclick(view.java:3823) 03-28 12:40:22.260: e/androidruntime(2579): @ android.view.view.performclick(view.java:4438) 03-28 12:40:22.260: e/androidruntime(2579): @ android.view.view$performclick.run(view.java:18422) 03-28 12:40:22.260: e/androidruntime(2579): @ android.os.handler.handlecallback(handler.java:733) 03-28 12:40:22.260: e/androidruntime(2579): @ android.os.handler.dispatchmessage(handler.java:95) 03-28 12:40:22.260: e/androidruntime(2579): @ android.os.looper.loop(looper.java:136) 03-28 12:40:22.260: e/androidruntime(2579): @ android.app.activitythread.main(activitythread.java:5017) 03-28 12:40:22.260: e/androidruntime(2579): @ java.lang.reflect.method.invokenative(native method) 03-28 12:40:22.260: e/androidruntime(2579): @ java.lang.reflect.method.invoke(method.java:515) 03-28 12:40:22.260: e/androidruntime(2579): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 03-28 12:40:22.260: e/androidruntime(2579): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 03-28 12:40:22.260: e/androidruntime(2579): @ dalvik.system.nativestart.main(native method) 03-28 12:40:22.260: e/androidruntime(2579): caused by: java.lang.reflect.invocationtargetexception 03-28 12:40:22.260: e/androidruntime(2579): @ java.lang.reflect.method.invokenative(native method) 03-28 12:40:22.260: e/androidruntime(2579): @ java.lang.reflect.method.invoke(method.java:515) 03-28 12:40:22.260: e/androidruntime(2579): @ android.view.view$1.onclick(view.java:3818) 03-28 12:40:22.260: e/androidruntime(2579): ... 11 more 03-28 12:40:22.260: e/androidruntime(2579): caused by: android.content.activitynotfoundexception: no activity found handle intent { act=com.example.gmapsapp.mainactivity } 03-28 12:40:22.260: e/androidruntime(2579): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1632) 03-28 12:40:22.260: e/androidruntime(2579): @ android.app.instrumentation.execstartactivity(instrumentation.java:1424) 03-28 12:40:22.260: e/androidruntime(2579): @ android.app.activity.startactivityforresult(activity.java:3424) 03-28 12:40:22.260: e/androidruntime(2579): @ android.app.activity.startactivityforresult(activity.java:3385) 03-28 12:40:22.260: e/androidruntime(2579): @ android.support.v4.app.fragmentactivity.startactivityforresult(fragmentactivity.java:817) 03-28 12:40:22.260: e/androidruntime(2579): @ android.app.activity.startactivity(activity.java:3627) 03-28 12:40:22.260: e/androidruntime(2579): @ android.app.activity.startactivity(activity.java:3595) 03-28 12:40:22.260: e/androidruntime(2579): @ com.example.gmapsapp.homepage.onclick(homepage.java:15) 03-28 12:40:22.260: e/androidruntime(2579): ... 14 more 03-28 12:40:36.530: e/androidruntime(2638): fatal exception: main 03-28 12:40:36.530: e/androidruntime(2638): process: com.example.gmapsapp, pid: 2638 03-28 12:40:36.530: e/androidruntime(2638): java.lang.illegalstateexception: not execute method of activity 03-28 12:40:36.530: e/androidruntime(2638): @ android.view.view$1.onclick(view.java:3823) 03-28 12:40:36.530: e/androidruntime(2638): @ android.view.view.performclick(view.java:4438) 03-28 12:40:36.530: e/androidruntime(2638): @ android.view.view$performclick.run(view.java:18422) 03-28 12:40:36.530: e/androidruntime(2638): @ android.os.handler.handlecallback(handler.java:733) 03-28 12:40:36.530: e/androidruntime(2638): @ android.os.handler.dispatchmessage(handler.java:95) 03-28 12:40:36.530: e/androidruntime(2638): @ android.os.looper.loop(looper.java:136) 03-28 12:40:36.530: e/androidruntime(2638): @ android.app.activitythread.main(activitythread.java:5017) 03-28 12:40:36.530: e/androidruntime(2638): @ java.lang.reflect.method.invokenative(native method) 03-28 12:40:36.530: e/androidruntime(2638): @ java.lang.reflect.method.invoke(method.java:515) 03-28 12:40:36.530: e/androidruntime(2638): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 03-28 12:40:36.530: e/androidruntime(2638): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 03-28 12:40:36.530: e/androidruntime(2638): @ dalvik.system.nativestart.main(native method) 03-28 12:40:36.530: e/androidruntime(2638): caused by: java.lang.reflect.invocationtargetexception 03-28 12:40:36.530: e/androidruntime(2638): @ java.lang.reflect.method.invokenative(native method) 03-28 12:40:36.530: e/androidruntime(2638): @ java.lang.reflect.method.invoke(method.java:515) 03-28 12:40:36.530: e/androidruntime(2638): @ android.view.view$1.onclick(view.java:3818) 03-28 12:40:36.530: e/androidruntime(2638): ... 11 more 03-28 12:40:36.530: e/androidruntime(2638): caused by: android.content.activitynotfoundexception: no activity found handle intent { act=com.example.gmapsapp.homepage2 } 03-28 12:40:36.530: e/androidruntime(2638): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1632) 03-28 12:40:36.530: e/androidruntime(2638): @ android.app.instrumentation.execstartactivity(instrumentation.java:1424) 03-28 12:40:36.530: e/androidruntime(2638): @ android.app.activity.startactivityforresult(activity.java:3424) 03-28 12:40:36.530: e/androidruntime(2638): @ android.app.activity.startactivityforresult(activity.java:3385) 03-28 12:40:36.530: e/androidruntime(2638): @ android.support.v4.app.fragmentactivity.startactivityforresult(fragmentactivity.java:817) 03-28 12:40:36.530: e/androidruntime(2638): @ android.app.activity.startactivity(activity.java:3627) 03-28 12:40:36.530: e/androidruntime(2638): @ android.app.activity.startactivity(activity.java:3595) 03-28 12:40:36.530: e/androidruntime(2638): @ com.example.gmapsapp.homepage.onclick1(homepage.java:18) 03-28 12:40:36.530: e/androidruntime(2638): ... 14 more 03-28 12:45:34.175: e/androidruntime(2714): fatal exception: main 03-28 12:45:34.175: e/androidruntime(2714): process: com.example.gmapsapp, pid: 2714 03-28 12:45:34.175: e/androidruntime(2714): java.lang.illegalstateexception: not execute method of activity 03-28 12:45:34.175: e/androidruntime(2714): @ android.view.view$1.onclick(view.java:3823) 03-28 12:45:34.175: e/androidruntime(2714): @ android.view.view.performclick(view.java:4438) 03-28 12:45:34.175: e/androidruntime(2714): @ android.view.view$performclick.run(view.java:18422) 03-28 12:45:34.175: e/androidruntime(2714): @ android.os.handler.handlecallback(handler.java:733) 03-28 12:45:34.175: e/androidruntime(2714): @ android.os.handler.dispatchmessage(handler.java:95) 03-28 12:45:34.175: e/androidruntime(2714): @ android.os.looper.loop(looper.java:136) 03-28 12:45:34.175: e/androidruntime(2714): @ android.app.activitythread.main(activitythread.java:5017) 03-28 12:45:34.175: e/androidruntime(2714): @ java.lang.reflect.method.invokenative(native method) 03-28 12:45:34.175: e/androidruntime(2714): @ java.lang.reflect.method.invoke(method.java:515) 03-28 12:45:34.175: e/androidruntime(2714): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 03-28 12:45:34.175: e/androidruntime(2714): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 03-28 12:45:34.175: e/androidruntime(2714): @ dalvik.system.nativestart.main(native method) 03-28 12:45:34.175: e/androidruntime(2714): caused by: java.lang.reflect.invocationtargetexception 03-28 12:45:34.175: e/androidruntime(2714): @ java.lang.reflect.method.invokenative(native method) 03-28 12:45:34.175: e/androidruntime(2714): @ java.lang.reflect.method.invoke(method.java:515) 03-28 12:45:34.175: e/androidruntime(2714): @ android.view.view$1.onclick(view.java:3818) 03-28 12:45:34.175: e/androidruntime(2714): ... 11 more 03-28 12:45:34.175: e/androidruntime(2714): caused by: android.content.activitynotfoundexception: no activity found handle intent { act=com.example.gmapsapp.mainactivity } 03-28 12:45:34.175: e/androidruntime(2714): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1632) 03-28 12:45:34.175: e/androidruntime(2714): @ android.app.instrumentation.execstartactivity(instrumentation.java:1424) 03-28 12:45:34.175: e/androidruntime(2714): @ android.app.activity.startactivityforresult(activity.java:3424) 03-28 12:45:34.175: e/androidruntime(2714): @ android.app.activity.startactivityforresult(activity.java:3385) 03-28 12:45:34.175: e/androidruntime(2714): @ android.support.v4.app.fragmentactivity.startactivityforresult(fragmentactivity.java:817) 03-28 12:45:34.175: e/androidruntime(2714): @ android.app.activity.startactivity(activity.java:3627) 03-28 12:45:34.175: e/androidruntime(2714): @ android.app.activity.startactivity(activity.java:3595) 03-28 12:45:34.175: e/androidruntime(2714): @ com.example.gmapsapp.homepage.onclick(homepage.java:15) 03-28 12:45:34.175: e/androidruntime(2714): ... 14 more 03-28 12:46:06.655: e/androidruntime(2800): fatal exception: main 03-28 12:46:06.655: e/androidruntime(2800): process: com.example.gmapsapp, pid: 2800 03-28 12:46:06.655: e/androidruntime(2800): java.lang.illegalstateexception: not execute method of activity 03-28 12:46:06.655: e/androidruntime(2800): @ android.view.view$1.onclick(view.java:3823) 03-28 12:46:06.655: e/androidruntime(2800): @ android.view.view.performclick(view.java:4438) 03-28 12:46:06.655: e/androidruntime(2800): @ android.view.view$performclick.run(view.java:18422) 03-28 12:46:06.655: e/androidruntime(2800): @ android.os.handler.handlecallback(handler.java:733) 03-28 12:46:06.655: e/androidruntime(2800): @ android.os.handler.dispatchmessage(handler.java:95) 03-28 12:46:06.655: e/androidruntime(2800): @ android.os.looper.loop(looper.java:136) 03-28 12:46:06.655: e/androidruntime(2800): @ android.app.activitythread.main(activitythread.java:5017) 03-28 12:46:06.655: e/androidruntime(2800): @ java.lang.reflect.method.invokenative(native method) 03-28 12:46:06.655: e/androidruntime(2800): @ java.lang.reflect.method.invoke(method.java:515) 03-28 12:46:06.655: e/androidruntime(2800): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 03-28 12:46:06.655: e/androidruntime(2800): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 03-28 12:46:06.655: e/androidruntime(2800): @ dalvik.system.nativestart.main(native method) 03-28 12:46:06.655: e/androidruntime(2800): caused by: java.lang.reflect.invocationtargetexception 03-28 12:46:06.655: e/androidruntime(2800): @ java.lang.reflect.method.invokenative(native method) 03-28 12:46:06.655: e/androidruntime(2800): @ java.lang.reflect.method.invoke(method.java:515) 03-28 12:46:06.655: e/androidruntime(2800): @ android.view.view$1.onclick(view.java:3818) 03-28 12:46:06.655: e/androidruntime(2800): ... 11 more 03-28 12:46:06.655: e/androidruntime(2800): caused by: android.content.activitynotfoundexception: no activity found handle intent { act=com.example.gmapsapp.fragmentactivity } 03-28 12:46:06.655: e/androidruntime(2800): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1632) 03-28 12:46:06.655: e/androidruntime(2800): @ android.app.instrumentation.execstartactivity(instrumentation.java:1424) 03-28 12:46:06.655: e/androidruntime(2800): @ android.app.activity.startactivityforresult(activity.java:3424) 03-28 12:46:06.655: e/androidruntime(2800): @ android.app.activity.startactivityforresult(activity.java:3385) 03-28 12:46:06.655: e/androidruntime(2800): @ android.support.v4.app.fragmentactivity.startactivityforresult(fragmentactivity.java:817) 03-28 12:46:06.655: e/androidruntime(2800): @ android.app.activity.startactivity(activity.java:3627) 03-28 12:46:06.655: e/androidruntime(2800): @ android.app.activity.startactivity(activity.java:3595) 03-28 12:46:06.655: e/androidruntime(2800): @ com.example.gmapsapp.homepage.onclick(homepage.java:15) 03-28 12:46:06.655: e/androidruntime(2800): ... 14 more 03-28 13:12:43.609: e/androidruntime(2883): fatal exception: main 03-28 13:12:43.609: e/androidruntime(2883): process: com.example.gmapsapp, pid: 2883 03-28 13:12:43.609: e/androidruntime(2883): java.lang.illegalstateexception: not execute method of activity 03-28 13:12:43.609: e/androidruntime(2883): @ android.view.view$1.onclick(view.java:3823) 03-28 13:12:43.609: e/androidruntime(2883): @ android.view.view.performclick(view.java:4438) 03-28 13:12:43.609: e/androidruntime(2883): @ android.view.view$performclick.run(view.java:18422) 03-28 13:12:43.609: e/androidruntime(2883): @ android.os.handler.handlecallback(handler.java:733) 03-28 13:12:43.609: e/androidruntime(2883): @ android.os.handler.dispatchmessage(handler.java:95) 03-28 13:12:43.609: e/androidruntime(2883): @ android.os.looper.loop(looper.java:136) 03-28 13:12:43.609: e/androidruntime(2883): @ android.app.activitythread.main(activitythread.java:5017) 03-28 13:12:43.609: e/androidruntime(2883): @ java.lang.reflect.method.invokenative(native method) 03-28 13:12:43.609: e/androidruntime(2883): @ java.lang.reflect.method.invoke(method.java:515) 03-28 13:12:43.609: e/androidruntime(2883): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 03-28 13:12:43.609: e/androidruntime(2883): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 03-28 13:12:43.609: e/androidruntime(2883): @ dalvik.system.nativestart.main(native method) 03-28 13:12:43.609: e/androidruntime(2883): caused by: java.lang.reflect.invocationtargetexception 03-28 13:12:43.609: e/androidruntime(2883): @ java.lang.reflect.method.invokenative(native method) 03-28 13:12:43.609: e/androidruntime(2883): @ java.lang.reflect.method.invoke(method.java:515) 03-28 13:12:43.609: e/androidruntime(2883): @ android.view.view$1.onclick(view.java:3818) 03-28 13:12:43.609: e/androidruntime(2883): ... 11 more 03-28 13:12:43.609: e/androidruntime(2883): caused by: android.content.activitynotfoundexception: no activity found handle intent { act=com.example.gmapsapp.mainactivity } 03-28 13:12:43.609: e/androidruntime(2883): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1632) 03-28 13:12:43.609: e/androidruntime(2883): @ android.app.instrumentation.execstartactivity(instrumentation.java:1424) 03-28 13:12:43.609: e/androidruntime(2883): @ android.app.activity.startactivityforresult(activity.java:3424) 03-28 13:12:43.609: e/androidruntime(2883): @ android.app.activity.startactivityforresult(activity.java:3385) 03-28 13:12:43.609: e/androidruntime(2883): @ android.support.v4.app.fragmentactivity.startactivityforresult(fragmentactivity.java:817) 03-28 13:12:43.609: e/androidruntime(2883): @ android.app.activity.startactivity(activity.java:3627) 03-28 13:12:43.609: e/androidruntime(2883): @ android.app.activity.startactivity(activity.java:3595) 03-28 13:12:43.609: e/androidruntime(2883): @ com.example.gmapsapp.homepage.onclick(homepage.java:15) 03-28 13:12:43.609: e/androidruntime(2883): ... 14 more 03-28 13:24:29.900: e/androidruntime(2947): fatal exception: main 03-28 13:24:29.900: e/androidruntime(2947): process: com.example.gmapsapp, pid: 2947 03-28 13:24:29.900: e/androidruntime(2947): java.lang.illegalstateexception: not execute method of activity 03-28 13:24:29.900: e/androidruntime(2947): @ android.view.view$1.onclick(view.java:3823) 03-28 13:24:29.900: e/androidruntime(2947): @ android.view.view.performclick(view.java:4438) 03-28 13:24:29.900: e/androidruntime(2947): @ android.view.view$performclick.run(view.java:18422) 03-28 13:24:29.900: e/androidruntime(2947): @ android.os.handler.handlecallback(handler.java:733) 03-28 13:24:29.900: e/androidruntime(2947): @ android.os.handler.dispatchmessage(handler.java:95) 03-28 13:24:29.900: e/androidruntime(2947): @ android.os.looper.loop(looper.java:136) 03-28 13:24:29.900: e/androidruntime(2947): @ android.app.activitythread.main(activitythread.java:5017) 03-28 13:24:29.900: e/androidruntime(2947): @ java.lang.reflect.method.invokenative(native method) 03-28 13:24:29.900: e/androidruntime(2947): @ java.lang.reflect.method.invoke(method.java:515) 03-28 13:24:29.900: e/androidruntime(2947): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 03-28 13:24:29.900: e/androidruntime(2947): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 03-28 13:24:29.900: e/androidruntime(2947): @ dalvik.system.nativestart.main(native method) 03-28 13:24:29.900: e/androidruntime(2947): caused by: java.lang.reflect.invocationtargetexception 03-28 13:24:29.900: e/androidruntime(2947): @ java.lang.reflect.method.invokenative(native method) 03-28 13:24:29.900: e/androidruntime(2947): @ java.lang.reflect.method.invoke(method.java:515) 03-28 13:24:29.900: e/androidruntime(2947): @ android.view.view$1.onclick(view.java:3818) 03-28 13:24:29.900: e/androidruntime(2947): ... 11 more 03-28 13:24:29.900: e/androidruntime(2947): caused by: android.content.activitynotfoundexception: no activity found handle intent { act=com.example.gmapsapp.mainactivity } 03-28 13:24:29.900: e/androidruntime(2947): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1632) 03-28 13:24:29.900: e/androidruntime(2947): @ android.app.instrumentation.execstartactivity(instrumentation.java:1424) 03-28 13:24:29.900: e/androidruntime(2947): @ android.app.activity.startactivityforresult(activity.java:3424) 03-28 13:24:29.900: e/androidruntime(2947): @ android.app.activity.startactivityforresult(activity.java:3385) 03-28 13:24:29.900: e/androidruntime(2947): @ android.support.v4.app.fragmentactivity.startactivityforresult(fragmentactivity.java:817) 03-28 13:24:29.900: e/androidruntime(2947): @ android.app.activity.startactivity(activity.java:3627) 03-28 13:24:29.900: e/androidruntime(2947): @ android.app.activity.startactivity(activity.java:3595) 03-28 13:24:29.900: e/androidruntime(2947): @ com.example.gmapsapp.homepage.onclick(homepage.java:15) 03-28 13:24:29.900: e/androidruntime(2947): ... 14 more
the mainfest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.gmapsapp" android:versioncode="1" android:versionname="1.0" > <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.access_network_state"/> <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-sdk android:minsdkversion="14" android:targetsdkversion="19" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/theme.notitlebar" > <activity android:name=".mainactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".homepage" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.maps.v2.api_key" android:value="aizasyafjx4umotxzayrsmyyeonne1puervgxea"/> </application> </manifest>
and sorry bad english
you haven't added crash logs error may here:
public void onclick(view view) { startactivity(new intent("com.example.gmapsapp.mainactivity")); }
i change this:
public void onclick(view view) { intent intent = new intent(this, mainactivity.class); startactivity(intent); }
or forgot declare activity google maps in manifest
Comments
Post a Comment