using intent on android to show activity -
using intent on android to show activity -
i have 2 activity
classes. have button on first 1 , want show sec when clicked, force close when ever run application. here classes:
public class app extends activity { private texttospeech tts; private button b1,b1a,b2,b2a,b3,b3a; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); /** called when activity first created. */ setcontentview(r.layout.main); tts = new texttospeech (this, null); b1 = (button)findviewbyid(r.id.btn_time); b1.setonlongclicklistener(new button.onlongclicklistener(){ @override public boolean onlongclick(view arg0) { string hi = "time"; tts.speak(hi, 0, null); homecoming false; }}); b1a = (button)findviewbyid(r.id.btn_time); b1a.setonclicklistener(new button.onclicklistener(){ public void onclick(view arg0){ { intent = new intent(app.this, time.class); startactivity(i); } } });
and link :
public class time extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.time); button btn = (button) findviewbyid(r.id.imagebutton1); btn.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { intent info = new intent(); textview txt_username = (textview) findviewbyid(r.id.imagebutton1); data.setdata(uri.parse( txt_username.gettext().tostring())); setresult(result_ok, data); finish(); } }); } } }
there no errors codes, forcefulness closes when button pressed. added time class manifest
, problem still persist. there anyway solve problem? in advance. :d
this current manifest.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.learn2develop.app" android:versioncode="1" android:versionname="1.0"> <uses-sdk android:minsdkversion="8" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".app" 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=".time" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.time" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
but, problem still persist. forcefulness closed after press button link time activity. , when check logcat
, says:
07-13 14:25:56.384: error/androidruntime(3799): android.content.activitynotfoundexception: unable find explicit activity class {net.learn2develop.app/android.text.format.time};
have declared activity in androidmanifest.xml?
problem in time activity don't have oncreatemethod on it.you declared oncreate on in inner class activity2 wrote start time activity app activity.
if write intent = new intent(app.this, time.class);
.it time activity.but didn't define time activity correctly.create oncreate method appropriate syntax on timer class activity
also check manifest file whether signed time activity or not
android android-activity android-intent
Comments
Post a Comment