The best way to do this is in your AndroidManifest.xml file. Just right click and open with the text editor in eclipse. Then add:
android:screenOrientation="landscape"
to your the activity that you want to be in landscape mode. Here's what my androidManifest.xml file looks like, sorry for the poor formatting options on Blogger:
Monday, August 30, 2010
How to Debug via USB Android
This is very easy if you are already setup with adb in eclipse:
1.plug in your device(phone)
2.enable USB debugging on device
3.debug/launch app from eclipse as normal, it will autoselect your device if it is attached.
If logcat isn't working, close and reopen eclipse.
1.plug in your device(phone)
2.enable USB debugging on device
3.debug/launch app from eclipse as normal, it will autoselect your device if it is attached.
If logcat isn't working, close and reopen eclipse.
Handle Multitouch Android
Here's the basics you need to know:
- setup an event handler to handle your ontouch events
- touch events have different actions: ACTION_DOWN, ACTION_UP, etc. are used for the first touch event registered. ACTION_POINTER_DOWN, ACTION_POINTER_UP are used for the second touch event. As far as I know Android only supports 2 touch events.
- to use the second event, you must combine the event.getAction() and MotionEvent.ACTION_MASK by anding them as seen below.
First you need to catch your action in your touch event and store it as an int:
public class GameEvent implements OnTouchListener{
public boolean onTouch(View v, MotionEvent event) {
actionCode = event.getAction() & MotionEvent.ACTION_MASK;//this combines single and multitouch
}
}
Then test to see what the event action was:
if(actionCode == MotionEvent.ACTION_DOWN){
}else if(actionCode == MotionEvent.ACTION_POINTER_DOWN )...
from here you can get the X&Y coordinates of each touch, the pressure, and more.
- setup an event handler to handle your ontouch events
- touch events have different actions: ACTION_DOWN, ACTION_UP, etc. are used for the first touch event registered. ACTION_POINTER_DOWN, ACTION_POINTER_UP are used for the second touch event. As far as I know Android only supports 2 touch events.
- to use the second event, you must combine the event.getAction() and MotionEvent.ACTION_MASK by anding them as seen below.
First you need to catch your action in your touch event and store it as an int:
public class GameEvent implements OnTouchListener{
public boolean onTouch(View v, MotionEvent event) {
actionCode = event.getAction() & MotionEvent.ACTION_MASK;//this combines single and multitouch
}
}
Then test to see what the event action was:
if(actionCode == MotionEvent.ACTION_DOWN){
}else if(actionCode == MotionEvent.ACTION_POINTER_DOWN )...
from here you can get the X&Y coordinates of each touch, the pressure, and more.
Sunday, August 29, 2010
Free Android Open Source On Screen Joystick
Surprisingly this is the only free on screen joystick I was able to find online that wasn't part of some other game engine. It's fairly straight forward and easy to implement.
The movement calculations were a little complex and didn't work for me, so I replaced them with this in the GameControls class:
//get the angle
//double angle = Math.atan2(_touchingPoint.y - inity,_touchingPoint.x - initx)/(Math.PI/180);
float xSpeed = _touchingPoint.x - initx;
float ySpeed = _touchingPoint.y - inity;
xSpeed *= 0.5;
ySpeed *= 0.5;
_pointerPosition.x += xSpeed;
_pointerPosition.y += ySpeed;
// Move the beetle in proportion to how far
// the joystick is dragged from its center
//_pointerPosition.y += Math.sin(angle*(Math.PI/180))*(_touchingPoint.x/70);
//_pointerPosition.x += Math.cos(angle*(Math.PI/180))*(_touchingPoint.x/70);
UPDATE: I am now using this for a dual joystick implementation. See my post on developing with multitouch in Android.
Here's the download and original forum post: http://trostalex.wordpress.com/2010/07/26/on-screen-joystick-source/
The movement calculations were a little complex and didn't work for me, so I replaced them with this in the GameControls class:
//get the angle
//double angle = Math.atan2(_touchingPoint.y - inity,_touchingPoint.x - initx)/(Math.PI/180);
float xSpeed = _touchingPoint.x - initx;
float ySpeed = _touchingPoint.y - inity;
xSpeed *= 0.5;
ySpeed *= 0.5;
_pointerPosition.x += xSpeed;
_pointerPosition.y += ySpeed;
// Move the beetle in proportion to how far
// the joystick is dragged from its center
//_pointerPosition.y += Math.sin(angle*(Math.PI/180))*(_touchingPoint.x/70);
//_pointerPosition.x += Math.cos(angle*(Math.PI/180))*(_touchingPoint.x/70);
UPDATE: I am now using this for a dual joystick implementation. See my post on developing with multitouch in Android.
Here's the download and original forum post: http://trostalex.wordpress.com/2010/07/26/on-screen-joystick-source/
Tuesday, August 17, 2010
Adw.launcher is sick
After experiencing the slow homescreen loading issues with 2.2, I decided to try out a couple custom launcher apps: launcher pro and adw.launcher.
Launcher pro is pretty handy in its own right, the only knock is that it only has 3 screens. On the other hand, the dock is extremely customizable. You can load and use your own images.
I chose adw because of the 5 homescreens, customizable dock, and smooth interface . I have not experienced any of the slow loading issues I had with the default homescreen on my droid. Definately a keeper, oh and its free.
Launcher pro is pretty handy in its own right, the only knock is that it only has 3 screens. On the other hand, the dock is extremely customizable. You can load and use your own images.
I chose adw because of the 5 homescreens, customizable dock, and smooth interface . I have not experienced any of the slow loading issues I had with the default homescreen on my droid. Definately a keeper, oh and its free.
Htc incredible low on memory, storage
A lot of people have been reporting memory issues with their htc droid incredibles. The phone is running slow, throwing errors left and right, and the battery lasts maybe two hours.
I believe this is due to the recent Facebook update for android, and the htc people application that comes with the sense ui. What happens is the facebook application tries to sync all of your contact info from facebook, even when your phone is supposed to be sleeping. Then something gets messed up in the people app, which holds your contacts, and an exorbant amount of memory is used up. To the point that you're phone can barely function.
The solution to this is to delete or opt out of sync with your facebook profile. Then delete your bloated contacts application. As I learned the hard way, make sure your contacts have been synched with google before deleting. They may not have even though you thought sync was turned on. A hard reset is not necessary as some have mentioned.
I asked the Verizon Rep about this when we went to the store to transfer contacts from an old phone back on to the incredible. He said he hadn't heard of the issue. Somehow I got the feeling I wasn't the first person he had told that to.
Subscribe to:
Comments (Atom)