java - Cannot launch any activity except the launcher activity -
first question on stackexchange hope can forgive me mistakes.
i developing app csipsimple project fork. whenever try launch activity intent or activity launcher app, app crashes.
here stack trace when try launch activities (it same activity except splashactivity launcher activity , runs fine.):
edit error (accidentally removed manifest entry problem persists.)
07-21 15:33:18.584: e/androidruntime(5827): fatal exception: main 07-21 15:33:18.584: e/androidruntime(5827): process: com.myapp.client, pid: 5827 07-21 15:33:18.584: e/androidruntime(5827): java.lang.runtimeexception: unable start activity componentinfo{com.myapp.client/com.myapp.client.loginactivity}: java.lang.nullpointerexception 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.activitythread.performlaunchactivity(activitythread.java:2184) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2233) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.activitythread.access$800(activitythread.java:135) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 07-21 15:33:18.584: e/androidruntime(5827): @ android.os.handler.dispatchmessage(handler.java:102) 07-21 15:33:18.584: e/androidruntime(5827): @ android.os.looper.loop(looper.java:136) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.activitythread.main(activitythread.java:5001) 07-21 15:33:18.584: e/androidruntime(5827): @ java.lang.reflect.method.invokenative(native method) 07-21 15:33:18.584: e/androidruntime(5827): @ java.lang.reflect.method.invoke(method.java:515) 07-21 15:33:18.584: e/androidruntime(5827): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) 07-21 15:33:18.584: e/androidruntime(5827): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) 07-21 15:33:18.584: e/androidruntime(5827): @ dalvik.system.nativestart.main(native method) 07-21 15:33:18.584: e/androidruntime(5827): caused by: java.lang.nullpointerexception 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.alertdialog.resolvedialogtheme(alertdialog.java:143) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.alertdialog.<init>(alertdialog.java:98) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.progressdialog.<init>(progressdialog.java:77) 07-21 15:33:18.584: e/androidruntime(5827): @ com.myapp.client.db.mysqlprovider.<init>(mysqlprovider.java:65) 07-21 15:33:18.584: e/androidruntime(5827): @ com.myapp.client.loginactivity.oncreate(loginactivity.java:69) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.activity.performcreate(activity.java:5231) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 07-21 15:33:18.584: e/androidruntime(5827): @ android.app.activitythread.performlaunchactivity(activitythread.java:2148) 07-21 15:33:18.584: e/androidruntime(5827): ... 11 more
following code splashactivity.java calls loginactivity.java
package com.myapp.client; public class splashactivity extends activity { protected boolean _active = true; protected int _splashtime = 3000; // time display splash screen in ms @override public void oncreate(bundle savedinstancestate) { this.requestwindowfeature(window.feature_no_title); if (build.version.sdk_int < 16) { getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); } else { view decorview = getwindow().getdecorview(); // hide status bar. int uioptions = view.system_ui_flag_fullscreen; decorview.setsystemuivisibility(uioptions); } defaultaccount(); super.oncreate(savedinstancestate); setcontentview(r.layout.activity_splash); thread splashtread = new thread() { @override public void run() { try { int waited = 0; while (_active && (waited < _splashtime)) { sleep(100); if (_active) { waited += 100; } } } catch (exception e) { } { startactivity(new intent(splashactivity.this, loginactivity.class)); finish(); } }; }; splashtread.start(); } private void defaultaccount(){ preferencesproviderwrapper prefwrap = new preferencesproviderwrapper(getapplicationcontext()); if (prefwrap.getpreferencebooleanvalue("initialrun", true)) { //set default account preferenceswrapper prefs = new preferenceswrapper(getapplicationcontext()); wizardinfo wizardinfo = wizardutils.getwizardclass("myapp"); wizardiface wizard = null; try { wizard = (wizardiface) wizardinfo.classobject.newinstance(); } catch (instantiationexception e) { log.e("myapp", "can't access wizard class", e); } catch (illegalaccessexception e) { // todo auto-generated catch block log.e("myapp", "can't access wizard class", e); } prefwrap.setpreferencebooleanvalue("initialrun", false); sipprofile account = sipprofile.getprofilefromdbid(this, sipprofile.invalid_id, dbprovider.account_full_projection); account = wizard.buildaccount(account); prefs.startediting(); wizard.setdefaultparams(prefs); prefs.endediting(); account.display_name = "myapp account"; account.username= "redacted"; account.wizard = "myapp"; account = wizard.buildaccount(account); account.acc_id = "redacted"; account.reg_uri = "redacted"; account.datatype=0; account.data="redacted"; account.use_rfc5626 = true; if(true) { if(textutils.isempty(account.rfc5626_instance_id)) { string autoinstanceid = (uuid.randomuuid()).tostring(); account.rfc5626_instance_id = "<urn:uuid:"+autoinstanceid+">"; } } uri uri = getcontentresolver().insert(sipprofile.account_uri, account.getdbcontentvalues()); account.id = contenturis.parseid(uri); list<filter> filters = wizard.getdefaultfilters(account); if (filters != null) { (filter filter : filters) { // ensure correct id if not done wizard filter.account = (int) account.id; getcontentresolver().insert(sipmanager.filter_uri, filter.getdbcontentvalues()); } } }} }
and here loginactivity.java
package com.myapp.client; public class loginactivity extends activity { mysqlprovider loginprovider; map<string,string> siplogin = null; edittext username; edittext password; @suppresslint("newapi") @override protected void oncreate(bundle savedinstancestate) { this.requestwindowfeature(window.feature_no_title); if (build.version.sdk_int < 16) { getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); } else { view decorview = getwindow().getdecorview(); // hide status bar. int uioptions = view.system_ui_flag_fullscreen; decorview.setsystemuivisibility(uioptions); } super.oncreate(savedinstancestate); setcontentview(r.layout.activity_login); username = (edittext)findviewbyid(r.id.username1); password = (edittext)findviewbyid(r.id.password1); loginprovider= new mysqlprovider(loginactivity.this); } public void loginsubmit(view view){ int responserecieved = generateresponse(); if (responserecieved == 0){ setsiplogin(siplogin); } generatedialog(responserecieved); } private int generateresponse(){ loginprovider.sqlconnect(); map<string,string> logininfo = null; connectivitymanager cm =(connectivitymanager)getapplicationcontext().getsystemservice(context.connectivity_service); networkinfo activenetwork = cm.getactivenetworkinfo(); boolean isconnected = activenetwork != null && activenetwork.isconnectedorconnecting(); if (!isconnected){return 3;} if (username.gettext().tostring() != "" && password.gettext().tostring() != ""){ logininfo = loginprovider.getlogininfo(username.gettext().tostring(), password.gettext().tostring()); } else return 2; if (logininfo.isempty() || logininfo == null){ return 1; } siplogin = logininfo; return 0; } private void generatedialog(int response){ switch (response){ case 0: break; case 1: alertdialog alertdialog = new alertdialog.builder(this).create(); alertdialog.settitle("myapp login"); alertdialog.setmessage("username or password not correct. please try again."); alertdialog.setbutton(dialoginterface.button_neutral, "ok", new message()); alertdialog.show(); break; case 2: alertdialog alertdialog1 = new alertdialog.builder(this).create(); alertdialog1.settitle("myapp login"); alertdialog1.setmessage("please fill required fields."); alertdialog1.setbutton(dialoginterface.button_neutral, "ok", new message()); alertdialog1.show(); break; case 3: alertdialog alertdialog2 = new alertdialog.builder(this).create(); alertdialog2.settitle("myapp login"); alertdialog2.setmessage("please provide internet connectivity"); alertdialog2.setbutton(dialoginterface.button_neutral, "ok", new message()); alertdialog2.show(); break; } } private void setsiplogin(map<string,string> siplogin){ preferencesproviderwrapper prefwrap = new preferencesproviderwrapper(getapplicationcontext()); //if (prefwrap.getpreferencebooleanvalue("initialrun", true)) //{ //set default account(disabled) preferenceswrapper prefs = new preferenceswrapper(getapplicationcontext()); wizardinfo wizardinfo = wizardutils.getwizardclass("myapp"); wizardiface wizard = null; try { wizard = (wizardiface) wizardinfo.classobject.newinstance(); } catch (instantiationexception e) { log.e("myapp", "can't access wizard class", e); } catch (illegalaccessexception e) { // todo auto-generated catch block log.e("myapp", "can't access wizard class", e); } //prefwrap.setpreferencebooleanvalue("initialrun", false); sipprofile account = sipprofile.getprofilefromdbid(this, 1, dbprovider.account_full_projection); account = wizard.buildaccount(account); prefs.startediting(); wizard.setdefaultparams(prefs); prefs.endediting(); string[] siploginparsed = siplogin.get("info").split(pattern.quote("#|#|#|#")); account.display_name = "myapp account"; account.username= siploginparsed[0]; account.wizard = "myapp"; account = wizard.buildaccount(account); account.acc_id = "redacted"; account.reg_uri = "redacted"; account.datatype=0; account.data=siploginparsed[1]; account.use_rfc5626 = true; if(true) { if(textutils.isempty(account.rfc5626_instance_id)) { string autoinstanceid = (uuid.randomuuid()).tostring(); account.rfc5626_instance_id = "<urn:uuid:"+autoinstanceid+">"; } } uri uri = getcontentresolver().insert(sipprofile.account_uri, account.getdbcontentvalues()); account.id = contenturis.parseid(uri); list<filter> filters = wizard.getdefaultfilters(account); if (filters != null) { (filter filter : filters) { // ensure correct id if not done wizard filter.account = (int) account.id; getcontentresolver().insert(sipmanager.filter_uri, filter.getdbcontentvalues()); } } startactivity(new intent(loginactivity.this,siphome.class)); } } //}
and here android manifest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myapp.client" android:installlocation="auto" android:versioncode="2459" android:versionname="1.02.03" > <uses-sdk android:minsdkversion="7" android:targetsdkversion="22" /> <application android:allowbackup="true" android:backupagent=".backup.sipbackupagent" android:hardwareaccelerated="true" android:icon="@drawable/ic_launcher_nightly" android:label="myapp" > <!-- <activity android:name=".ui.siphome" android:label="@string/app_name" android:launchmode="singletask" android:theme="@style/darktheme" android:uioptions="splitactionbarwhennarrow" > <intent-filter android:priority="10" > <action android:name="com.myapp.client.phone.action.dialer" /> <category android:name="android.intent.category.default" /> </intent-filter> <intent-filter android:priority="10" > <action android:name="android.intent.action.dial" /> <category android:name="android.intent.category.default" /> <data android:scheme="sip" /> <data android:scheme="csip" /> </intent-filter> <intent-filter android:priority="10" > <action android:name="com.myapp.client.phone.action.calllog" /> <category android:name="android.intent.category.default" /> </intent-filter> <intent-filter android:priority="10" > <action android:name="com.myapp.client.phone.action.favorites" /> <category android:name="android.intent.category.default" /> </intent-filter> <intent-filter android:priority="10" > <action android:name="com.myapp.client.phone.action.messages" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity-alias android:name=".ui.sipdialer" android:label="@string/app_name" android:launchmode="singletask" android:targetactivity=".ui.siphome" android:theme="@style/darktheme" android:uioptions="splitactionbarwhennarrow" > <intent-filter> <action android:name="android.intent.action.view" /> <action android:name="android.intent.action.sendto" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> <data android:scheme="csip" /> <data android:scheme="sip" /> <data android:scheme="sips" /> <data android:scheme="sms" /> <data android:scheme="smsto" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.view" /> <action android:name="android.intent.action.sendto" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> <data android:host="csip" android:scheme="imto" /> <data android:host="sip" android:scheme="imto" /> <data android:host="skype" android:scheme="imto" /> </intent-filter> </activity-alias> <!-- main service --> <!-- require @ least configure permission use --> <service android:name=".service.sipservice" android:exported="true" android:permission="android.permission.configure_sip" android:process=":sipstack" > <intent-filter> <action android:name="com.myapp.client.service.sipservice" /> <action android:name="com.myapp.client.service.sipconfiguration" /> </intent-filter> </service> <service android:name=".service.downloader" /> <!-- main ui --> <activity android:name=".ui.calllog.calllogdetailsactivity" android:theme="@style/darktheme" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".ui.prefs.cupcake.mainprefs" android:configchanges="orientation" android:enabled="@bool/use_cupcake_prefs" android:label="@string/prefs" android:permission="android.permission.configure_sip" android:theme="@style/darktheme" > <intent-filter> <action android:name="com.myapp.client.ui.action.prefs_global" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".ui.prefs.cupcake.prefsloaderactivity" android:label="" android:theme="@style/darktheme" /> <activity android:name=".ui.prefs.prefsfilters" android:configchanges="orientation" android:label="@string/filters" android:theme="@style/darktheme" /> <activity android:name=".ui.prefs.prefsfast" android:configchanges="orientation" android:label="@string/prefs_fast" android:permission="android.permission.configure_sip" android:theme="@style/darktheme.dialog" > <intent-filter> <action android:name="com.myapp.client.ui.action.prefs_fast" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".ui.prefs.codecs" android:configchanges="orientation" android:label="@string/codecs" android:theme="@style/darktheme" /> <activity android:name=".ui.prefs.audiotester" android:label="@string/test_audio" android:screenorientation="portrait" android:theme="@style/darktheme.dialog" /> <!-- wizards --> <activity android:name=".wizards.baseprefswizard" android:configchanges="orientation" android:label="@string/edit" android:theme="@style/darktheme" /> <!-- call management --> <receiver android:name=".service.outgoingcall" android:permission="android.permission.call_phone" android:process=":sipstack" > <!-- here filter protected-broadcasts --> <intent-filter android:priority="0" > <action android:name="android.intent.action.new_outgoing_call" /> </intent-filter> </receiver> <activity android:name=".ui.outgoingcall.outgoingcallchooser" android:allowtaskreparenting="false" android:configchanges="orientation" android:excludefromrecents="true" android:label="@string/call" android:launchmode="singletask" android:permission="android.permission.use_sip" android:process=":sipstack" android:taskaffinity="" android:theme="@style/darktheme.dialog" > <intent-filter> <action android:name="android.intent.action.call" /> <category android:name="android.intent.category.default" /> <data android:scheme="csip" /> <data android:scheme="sip" /> <data android:scheme="sips" /> </intent-filter> <intent-filter android:priority="10" > <action android:name="android.phone.extra.new_call_intent" /> <category android:name="android.intent.category.default" /> <data android:scheme="csip" /> <data android:scheme="sip" /> <data android:scheme="sips" /> </intent-filter> </activity> <activity-alias android:name=".ui.privilegedoutgoingsipcallbroadcaster" android:configchanges="orientation" android:excludefromrecents="true" android:launchmode="singletask" android:permission="android.permission.call_privileged" android:targetactivity=".ui.outgoingcall.outgoingcallchooser" android:theme="@style/darktheme.dialog" > <intent-filter> <action android:name="android.intent.action.call_privileged" /> <category android:name="android.intent.category.default" /> <data android:scheme="sip" /> </intent-filter> </activity-alias> <activity-alias android:name=".ui.privilegedoutgoingcallbroadcaster" android:configchanges="orientation" android:enabled="false" android:excludefromrecents="true" android:label="@string/sip_call" android:launchmode="singletask" android:permission="android.permission.call_privileged" android:targetactivity=".ui.outgoingcall.outgoingcallchooser" android:theme="@style/darktheme.dialog" > <intent-filter> <action android:name="android.intent.action.call_privileged" /> <category android:name="android.intent.category.default" /> <data android:scheme="tel" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.call_privileged" /> <category android:name="android.intent.category.default" /> <data android:mimetype="vnd.android.cursor.item/phone" /> <data android:mimetype="vnd.android.cursor.item/phone_v2" /> <data android:mimetype="vnd.android.cursor.item/person" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.sendto" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> <data android:scheme="sms" /> <data android:scheme="smsto" /> </intent-filter> </activity-alias> <!-- able video, has launched in sipstack process --> <activity android:name=".ui.incall.incallactivity" android:allowtaskreparenting="true" android:configchanges="orientation" android:excludefromrecents="true" android:launchmode="singletask" android:permission="android.permission.configure_sip" android:process=":sipstack" android:taskaffinity="" android:theme="@style/darktheme.notitle" > <intent-filter android:priority="10" > <action android:name="com.myapp.client.phone.action.incall" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".ui.pickupsipuri" android:configchanges="orientation" android:label="@string/pickup_sip_uri" android:theme="@style/darktheme" /> <activity android:name=".ui.incall.incallmediacontrol" android:configchanges="orientation" android:label="@string/prefs_media" android:taskaffinity="com.myapp.client.ui.incall.incallactivity" android:theme="@style/darktheme.dialog" /> <!-- new ui --> <activity android:name=".ui.account.accountseditlist" android:label="@string/accounts" android:theme="@style/darktheme" /> <activity android:name=".ui.account.accountedit" android:theme="@style/darktheme" /> <activity android:name=".splashactivity" android:label="@string/app_name" android:nohistory="true" android:theme="@style/theme.sherlock.noactionbar" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> <category android:name="android.intent.category.multiwindow_launcher" /> </intent-filter> </activity> <activity android:name=".loginactivity" android:nohistory="true" android:configchanges="orientation" android:label="loginactivity" /> </application> </manifest>
android manifest , parts of code redacted 30000 chars.(receivers , providers imports) same error occurs when try launch activity activity launcher app.
you're missing declare loginactivity in manifest.
<activity android:name=".loginactivity" android:configchanges="orientation" android:label="loginactivity" />
there's no way start activity if not declared.
Comments
Post a Comment