Re: 답장: [android-beginners] Null Pointer Excepti on when using a button to change layouts
Hi, I'm not sure you need to use startActivityForResult, start with startActivty like that : Intent intent = new Intent(NextActivity.this, Hello_Android.class); startActivity(intent); Another problem I think is that you need to : implements View.OnClickListener to make it work. To this, maybe it will help... On 10 fév, 00:29, 안드로이드카이로 kair...@gmail.com wrote: You write setcontentview before setonclicklistener. Http://www.androidside.com 2010. 2. 10. 오전 7:46에 Anthony Westover anthony.westo...@valpo.edu님이 작성: I am new to android development, experienced with Java. I am trying, basically, to play around with OnClick events, using a button click to change Layouts. I started by making two .xml files in my Layouts folder of the project and just setting setContentView to the first xml in onCreate and to the other xml in onClick. Through some searching I found that another Activity and an Intent object. I tried this with the following: package org.Android.HelloAndroid; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class NextActivity extends Activity{ public void onCreate(Bundle bundle){ super.onCreate(bundle); Button button = (Button) findViewById(R.id.goback); button.setOnClickListener(new OnClickListener(){ public void onClick(View v){ Intent myIntent = new Intent(v.getContext(), Hello_Android.class); startActivityForResult(myIntent,0); } }); setContentView(R.layout.onclick); } } package org.Android.HelloAndroid; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.*; public class Hello_Android extends Activity{ /** Called when the activity is first created. */ �...@override public void onCreate(Bundle created) { super.onCreate(created); TextView tv = (TextView) findViewById(R.id.textview); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener(){ public void onClick(View v){ Intent myIntent = new Intent(v.getContext(),NextActivity.class); startActivityForResult(myIntent,0); } }); this.setContentView(R.layout.main); } } When I run this I get the error: The application Hello_Android (process org.android.HelloAndroid) has stopped unexpectedly. Please try again. Force Close. I used logcat, which I will be the first to admit I am unfamiliar with how to read, but what stood out was the java Stack trace, E/AndroidRuntime( 180): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 180): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.Android.HelloAndroid/ org.Android.HelloAndroid.Hello_Android}: java.lang.NullPointerException E/AndroidRuntime( 180): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2496) E/AndroidRuntime( 180): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2512) E/AndroidRuntime( 180): at android.app.ActivityThread.access $2200(ActivityThread.java:119) E/AndroidRuntime( 180): at android.app.ActivityThread $H.handleMessage(ActivityThread.java:1863) E/AndroidRuntime( 180): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 180): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 180): at android.app.ActivityThread.main(ActivityThread.java:4363) E/AndroidRuntime( 180): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 180): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 180): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:860) E/AndroidRuntime( 180): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) E/AndroidRuntime( 180): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 180): Caused by: java.lang.NullPointerException E/AndroidRuntime( 180): at org.Android.HelloAndroid.Hello_Android.onCreate(Hello_Android.java:17) E/AndroidRuntime( 180): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1047) E/AndroidRuntime( 180): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2459) What is the most interesting to me is the null pointer exception at line 17 of Hello_Android.java, the line in question being:
[android-beginners] Communicating with local computer
Hi! If I connect an Android Phone to PC using USB cable, what options do I have in communicating between the phone and the PC? I would like to achieve following communication features in my application: 1) Java application on PC should be able to recognize when a phone with my app is connected or disconnected via USB, 2) Phone should recognize if the PC has my app running or not and 3) Phone and PC should be able to transfer textual data in both directions. [Application on Phone] -USB-- [Application on PC] Only thing really coming to my mind is to use TCP for data transfer and UDP for presence, but I don't even know if this is possible with Android. The idea is to enable cable connection, so TCP may not be the nicest way. So could someone give me some advice what options I have, and how should I get started? Best Regards, Antti Karhu -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Catching and changing a keycode.
Hi Ryan, you can modify the behavior in android framework. You need to change the following files: base/core/res/res/values/attrs.xml base/core/java/android/view/KeyEvent.java in this files you can change the code of the keys to do what you want. Regards, Rogerio 2010/2/7 Ryan Rogers ryansroger...@gmail.com Hello all, I understand how to listen for a key press, but I was wondering if there was a way to catch it, and change it. for example, if I press the 's' key, and I wanted to change it to the 'g' key. Not for typing on the board, but for the system to think I pressed the 'g' button instead of the 's' button. Thanks in advance, -Ryan -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: How to make a animated ( live ) Wallpaper
/push On Feb 1, 11:25 am, Michbeck michael.trank...@gmail.com wrote: Is there a good tutorial on how to code a animated / livewallpaper? i couldn't find decent help on how to do this except the android reference onwallpaperclass. link:http://developer.android.com/reference/android/app/WallpaperInfo.html But i think i need some more information to get started. Another thing i don't get is: is an animatedwallpapersimply a .gif which is animated but has some code to respond to touches for example or is it a android application in some sort of way ? Thanks for clearing it :D Michbeck -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: Launch other activity on pressing the on-screen camera/camcorder button?
Tried this... doesn't work :( On Feb 5, 1:36 pm, Abhi abhishek.r.sha...@gmail.com wrote: Great! I will try this out right away. Thanks Roger. Appreciate it. Abhi On Feb 5, 12:47 pm, Rogério de Souza Moraes rogerio.so...@gmail.com wrote: HiAbhi, it is possible. You can do like this: private class ExpandedDialog extends Dialog { ExpandedDialog(Context context) { super(context, com.android.internal.R.style.Theme_Light_NoTitleBar); } @Override public boolean dispatchKeyEvent(KeyEvent event) { boolean down = event.getAction() == KeyEvent.ACTION_DOWN; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: if (!down) { StatusBarService.this.deactivate(); } return true; } return super.dispatchKeyEvent(event); } } This example is inside the file StatusBarService.java in SDK. Here, this class gets the event when the user presses the back button and execute his function. Regards, Rogerio 2010/2/5Abhiabhishek.r.sha...@gmail.com Hi, Is it possible to launch another activity or invoke a sensor (e.g. accelerometer) on the press of capture or video record button? Abhi -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Re: Launch other activity on pressing the on-screen camera/camcorder button?
Hi Abhi, can you paste the code? Maybe I can help better with more information. Regards, Rogerio 2010/2/10 Abhi abhishek.r.sha...@gmail.com Tried this... doesn't work :( On Feb 5, 1:36 pm, Abhi abhishek.r.sha...@gmail.com wrote: Great! I will try this out right away. Thanks Roger. Appreciate it. Abhi On Feb 5, 12:47 pm, Rogério de Souza Moraes rogerio.so...@gmail.com wrote: HiAbhi, it is possible. You can do like this: private class ExpandedDialog extends Dialog { ExpandedDialog(Context context) { super(context, com.android.internal.R.style.Theme_Light_NoTitleBar); } @Override public boolean dispatchKeyEvent(KeyEvent event) { boolean down = event.getAction() == KeyEvent.ACTION_DOWN; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: if (!down) { StatusBarService.this.deactivate(); } return true; } return super.dispatchKeyEvent(event); } } This example is inside the file StatusBarService.java in SDK. Here, this class gets the event when the user presses the back button and execute his function. Regards, Rogerio 2010/2/5Abhiabhishek.r.sha...@gmail.com Hi, Is it possible to launch another activity or invoke a sensor (e.g. accelerometer) on the press of capture or video record button? Abhi -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com android-beginners%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: connect 2 emulators over lan
you can create two different emulators in eclipse with the same properties, but name them different and start them both in eclipse. They can text and call each other. On Feb 5, 4:39 am, ABTHUL RAZEETH abthulraze...@gmail.com wrote: I have tried with two emulators running in same machine with tcp redirecting. I have also tried with two emulators running in two different machines, but it didn't work out since each emulator runs behind its own proxy. I am also looking for some solution. With regards abthulOn Fri, Feb 5, 2010 at 10:59 AM, arin arinv1618b...@gmail.com wrote: Is it possible to connect 2 emulators e1 e2 running separately in machines m1 m2 connected over a ethernet LAN cable to send and receive data? note that I dont want to use internet at this point and my app will purely be designed as a local server-client app for testing. I am looking for a specific answer. Will appreciate if anyone can refer some examples too... regards, Arin -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.comandroid-beginners%2Bunsubscr i...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] This Week's office hours
Each week, we hold office hours in android-dev channel on irc.freenode.netto get your Android application development related questions answered. They take place at the following time: Thursdays 5pm to 6pm PST weekly. You can use this tool to see what time it is in your timezone http://www.timeanddate.com/worldclock/converter.html?month=2day=11year=2010hour=17min=0sec=0p1=224http://www.google.com/url?sa=Dq=http://www.timeanddate.com/worldclock/converter.html%3Fyear%3D2010%26month%3D2%26day%3D4%26hour%3D16%26min%3D0%26sec%3D0%26p1%3D240%26p2%3D224usg=AFQjCNFd9c-HuJdJbFFDRPjFXaXE2XwmhA Office hours are also listed on this calendar (which defaults to US Pacific timezone): http://code.google.com/events/calendar/http://www.google.com/url?sa=Dq=http://code.google.com/events/calendar/usg=AFQjCNHDBYQtR7jk4XQZgBNYDd2Uplshxw You can add it to your calendar from there, and if your calendar is setup appropriately, it should show up at your local time. See you there! -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: Serial over Bluetooth
Based on my experience so far (and the information provided on Android site), SPP (Serial Port Profile) is not supported by existing Android SDK (as of Feb 2010). On a funny note, one of our developers managed to get a signal out and receive a reply using Bluetooth SPP on Android Dev Phone running SDK 1.6. I do not have any additional information at this time as that developer was switched to another project. Hope this answers the question (and know that it will not help at all), M. -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en