java - Android studio crashing after Intent hit -
i want ask why intenting activity makes system crashed? i've created 2 layout, 1 of them named "mainactivity" , other 1 named "login". in main activity there button, want pop login activity after hitting button. because want view list view i've been created see if right or wrong. problem here whenever hit button crashed. me please.
main activity
public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } public void okay(view view) { intent = new intent(this, login.class); startactivity(i); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; }
login ###
public class login extends actionbaractivity { listview listview; arrayadapter<string> adapter; string[] grocery_categories = {"beverages", "bakery", "canned goods", "condiments", "dairy", "snacks", "frozen foods", "meat", "produce", "cleaners", "paper goods", "personal care", "others"}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_login); listview = (listview) findviewbyid(r.id.list_view); adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1, grocery_categories); listview.setadapter(adapter); listview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> listview, view view, int position, long id) { string grocery = (string) listview.getadapter().getitem(position); intent intent = new intent(listview.getcontext(),login.class); listview.getcontext().startactivity(intent); //or create other intents here } }); }
main activity 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" tools:context=".mainactivity" android:id="@+id/rl_main_activity"> <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/mobile_grocery_bckgrnd" android:src="@drawable/mobile_grocery" android:scaletype="centercrop" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="mobile grocery" android:id="@+id/mobile_grocery_app" android:textsize="45dp" android:textcolor="#000000" android:gravity="center" android:textstyle="bold|italic" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="application" android:id="@+id/application" android:textcolor="#000000" android:textsize="25dp" android:layout_below="@+id/mobile_grocery_app" android:layout_centerhorizontal="true" /> <edittext android:layout_width="200dp" android:layout_height="wrap_content" android:id="@+id/username" android:layout_alignparentbottom="true" android:layout_alignright="@+id/application" android:layout_alignend="@+id/application" android:layout_marginbottom="135dp" android:hint="username" android:textcolorhint="#000000" /> <edittext android:layout_width="200dp" android:layout_height="wrap_content" android:id="@+id/password" android:layout_aligntop="@+id/username" android:layout_alignright="@+id/username" android:layout_alignend="@+id/username" android:layout_margintop="52dp" android:hint="password" android:textcolorhint="#000000" android:password="true" /> <button style="?android:attr/buttonstylesmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ok" android:id="@+id/ok" android:layout_below="@+id/password" android:layout_alignleft="@+id/application" android:layout_alignstart="@+id/application" android:onclick="okay" />
login
<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" tools:context="com.example.admin.mobilegroceryapp.login" android:id="@+id/rl_login"> <imageview android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/login_bckgrnd" android:src="@drawable/login_bckgrnd" android:scaletype="centercrop" /> <listview android:id="@+id/list_view" android:layout_width="match_parent" android:layout_height="wrap_content"> </listview>
logcat
09-30 11:10:39.957 2019-2210/? e/watchdog﹕ !@sync 8890 09-30 11:10:41.812 1735-19431/? e/omxcodec﹕ [omx.sec.mp3.decoder] err = -1011 09-30 11:10:41.882 1735-6638/? e/omxcodec﹕ [omx.sec.mp3.decoder] err = -1011 09-30 11:10:41.992 1735-20195/? e/omxcodec﹕ [omx.sec.mp3.decoder] err = -1011 09-30 11:10:42.117 1735-19431/? e/mp3extractor﹕ unable resync. signalling end of stream. 09-30 11:10:42.117 1735-19431/? e/omxcodec﹕ [omx.sec.mp3.decoder] err = -1011 09-30 11:10:42.192 1735-6638/? e/omxcodec﹕ [omx.sec.mp3.decoder] err = -1011 09-30 11:10:42.262 1735-20195/? e/omxcodec﹕ [omx.sec.mp3.decoder] err = -1011 09-30 11:10:45.782 14900-14900/? e/mtpserverjni﹕ not open mtp driver, errno: 2 09-30 11:10:45.787 14900-14917/? e/mtpserverjni﹕ server null in run 09-30 11:10:45.787 14900-14917/? e/mtpserverjni﹕ server null in cleanup 09-30 11:11:02.912 4074-4074/? e/mtpservice﹕ in mtpapp onreceive:android.intent.action.battery_changed 09-30 11:11:02.912 4074-4074/? e/mtpservice﹕ battplugged type : 2 09-30 11:11:09.957 2019-2210/? e/watchdog﹕ !@sync 8891 09-30 11:11:15.392 14943-14943/? e/dalvikvm﹕ not find class 'android.app.appopsmanager', referenced method com.google.android.gms.common.googleplayservicesutil.zza 09-30 11:11:16.807 14969-14969/? e/dalvikvm﹕ not find class 'com.google.android.gms.common.h.c', referenced method com.google.android.gms.common.app.gmsapplication.oncreate 09-30 11:11:17.317 28048-28048/? e/authorizationbluetoothservice﹕ proximity feature not enabled. 09-30 11:11:17.492 14969-14969/? e/dalvikvm﹕ not find class 'android.telecom.telecommanager', referenced method com.google.android.gms.wearable.service.y.a 09-30 11:11:17.712 14969-14980/? e/dalvikvm﹕ not find class 'android.app.appopsmanager', referenced method com.google.android.gms.common.kz.a 09-30 11:11:17.757 14969-14980/? e/dalvikvm﹕ not find class 'android.os.usermanager', referenced method com.google.android.gms.common.kz.j 09-30 11:11:17.872 14943-14943/? e/connectionservice﹕ failed connect googleapiclient: connectionresult{statuscode=api_unavailable, resolution=null} 09-30 11:11:21.612 14943-15002/? e/gmsutils﹕ failed connect google api client: connectionresult{statuscode=api_unavailable, resolution=null} 09-30 11:11:39.962 2019-2210/? e/watchdog﹕ !@sync 8892 09-30 11:11:43.047 4074-4074/? e/mtpservice﹕ in mtpapp onreceive:android.intent.action.battery_changed 09-30 11:11:43.047 4074-4074/? e/mtpservice﹕ battplugged type : 2 09-30 11:11:45.397 15132-15132/? e/samsung tts﹕ onloadlanguage() - lang : eng, country : gbr, variant : 09-30 11:11:45.397 15132-15132/? e/samsung tts﹕ onislanguageavailable() - lang : eng, country : gbr, variant : , iresult : 1 09-30 11:11:45.397 15132-15132/? e/samsung tts﹕ onloadlanguage() - lang_country_available 09-30 11:11:45.397 15132-15132/? e/samsung tts﹕ onloadlanguage() - lang : eng, country : gbr, variant : f01 09-30 11:11:45.687 15132-15132/? e/samsung tts﹕ oncreate() - samsung tts package (released - 2012.06.14) 09-30 11:11:45.687 15132-15132/? e/﹕ samsung tts engine - initialize() : samsung tts engine (released - 2012.07.11) 09-30 11:11:45.687 15132-15132/? e/﹕ samsung tts engine - initialize() : ro.product.manufacturer - samsung 09-30 11:11:45.697 15132-15143/? e/samsung tts﹕ onloadlanguage() - lang : eng, country : , variant : 09-30 11:11:45.697 15132-15143/? e/samsung tts﹕ onislanguageavailable() - lang : eng, country : , variant : , iresult : 0 09-30 11:11:45.697 15132-15143/? e/samsung tts﹕ onloadlanguage() - lang_available 09-30 11:11:45.697 15132-15143/? e/samsung tts﹕ onloadlanguage() - lang : eng, country : usa, variant : f01 09-30 11:11:45.847 15132-15144/? e/samsung tts﹕ onislanguageavailable() - lang : eng, country : , variant : , iresult : 0 09-30 11:12:09.962 2019-2210/? e/watchdog﹕ !@sync 8893 09-30 11:12:22.132 15191-15234/? e/dalvikvm﹕ not find class 'android.telephony.cellinfocdma', referenced method com.facebook.common.hardware.celldiagnosticsserializer.c 09-30 11:12:23.157 4074-4074/? e/mtpservice﹕ in mtpapp onreceive:android.intent.action.battery_changed 09-30 11:12:23.157 4074-4074/? e/mtpservice﹕ battplugged type : 2 09-30 11:12:27.297 15191-15191/? e/dalvikvm﹕ not find class 'android.app.appopsmanager', referenced method com.google.android.gms.common.googleplayservicesutil.a 09-30 11:12:29.802 15191-15191/? e/dalvikvm﹕ not find class 'com.facebook.push.adm.admbroadcastreceiver', referenced method com.facebook.push.adm.admpushmanager.b 09-30 11:12:31.892 2019-2087/? e/inputdispatcher﹕ channel ~ channel unrecoverably broken , disposed! 09-30 11:12:32.182 2019-2087/? e/inputdispatcher﹕ received spurious receive callback unknown input channel. fd=217, events=0x9 09-30 11:12:33.812 15191-15300/? e/fb4a(:<default>):vaultdevicesetup﹕ setupdevicefromserver
manifest
<application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".mainactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".login" android:label="@string/title_activity_login" > </activity>
try code
public void okay(view view) { intent = new intent(mainactivity.this, login.class); startactivity(i); }
Comments
Post a Comment