XDA2 Button assignments lost! Help please! - General Topics

Hello all !
All Button assignments were lost after
for (i = 0xc1; i < 0xcf; i++)
{
BOOL bResult1 = m_fnUndergisterFunc(MOD_WIN, i);
BOOL bResult2 = RegisterHotKey(NULL, i, MOD_WIN, i);
}
Help to get them back, please.
Could someone tell me what is written in the following registry keys for the XDA2.
HKLM,Software\Microsoft\Shell\Keys\40C1
HKLM,Software\Microsoft\Shell\Keys\40C2
HKLM,Software\Microsoft\Shell\Keys\40C3
HKLM,Software\Microsoft\Shell\Keys\40C4
HKLM,Software\Microsoft\Shell\Keys\40C5
Thanks a lot in advance.

can't you just simple use "Restore defaults" ?

Related

System time problem

I have the following code to retrieve the current system time
Code:
public static String getCurrentTimeAsString() {
Calendar cal = Calendar.getInstance();
StringBuffer sBuf = new StringBuffer();
int month = cal.get(Calendar.MONTH) + 1;
sBuf.append(month);
sBuf.append("-");
sBuf.append(cal.get(Calendar.DATE));
sBuf.append("-");
sBuf.append(cal.get(Calendar.YEAR));
sBuf.append(" ");
sBuf.append(cal.get(Calendar.HOUR_OF_DAY));
sBuf.append(":");
sBuf.append(cal.get(Calendar.MINUTE));
sBuf.append(":");
sBuf.append(cal.get(Calendar.SECOND));
return sBuf.toString();
}
The code works fine on all devices except on windows mobile with Esmertec Jbed platform, where I am getting a completely wrong time.
Any help in this regard will be highly appreciated.
What's wrong with DateTime.Now.ToString(datetime format string) ?
Ta
Dave

MapActivity, Buttons and OnClickListener

Hi all,
could you give me some help please? I have written a simple MapActivity that contains a mapview (defined in the xml file); it also contains a Button.
If the Button has no OnClickListener associated then the project runs fine (the mapview is of course empty).
If I add an OnclickListener the application simply Force closes.
Has anyone tried this? I was actually following the example in a book but I guess something has changed in the SDK since it was written?
I m using SDK 1.1 (for the moment).
If you have (recently) written something similar, could you give me some pointers please?
thanks
N
"could you give me some pointers please?"
Might be a nullpointer indeed. Check your LogCat (Eclipse: Window, show view, other, logcat), this will probably give you some nice hints.
LOL
ehhehe
havent checked the log yet, will do and then report back here.
if anyone else has other suggestions please dont hesitate!
thanks
N
LogCat
Vlemmix said:
"could you give me some pointers please?"
Might be a nullpointer indeed. Check your LogCat (Eclipse: Window, show view, other, logcat), this will probably give you some nice hints.
Click to expand...
Click to collapse
Vlemmix,
I checked the LogCat and seems too be a nullpointer indeed, but I cannot identify the mistake in the code.
This is the java source for the class. could you please have a look ?
If I un-comment the commented lines, I get a force close. Leave them uncommented and everything works (no click event on the button tho).
package com.chipset.testgps;
import com.google.android.maps.MapView;
import android.widget.Button;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
public class main extends MapActivity {
@Override
public boolean isRouteDisplayed(){
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Button but = (Button) findViewById(R.id.gpsButton);
// but.setOnClickListener(new View.OnClickListener() {
// public void onClick(View v){
//
// }
// });
final MapView map = (MapView) findViewById(R.id.myMap);
setContentView(R.layout.main);
}
}
Any help please??
thanks
N
1)
First do the setContentView, after that the Button is findable. The system could not find your Button now, so that's why it is a null. Your MapView map also would be a null in your code.
2)
If you define an object within {} it is only available within that {}
You probably going to need the Object "but" later, so make it a private variable of the class.
3)
Classname should start with a capital.
4) Visit anddev.org or some site like that for coding problems, xda seems to be more focused on system/firmware issues, not application code.
So, this should work:
public class MainActivity extends MapActivity {
final Button but;
final MapView map;
@Override
public boolean isRouteDisplayed() {
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
but = (Button) findViewById(R.id.gpsButton);
but.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
}
});
map = (MapView) findViewById(R.id.myMap);
}
}
Right
Hi Vlemmix.
Thanks very much for your help. I can understand what you are telling me, but if its so:
1) with the listener's lines commented, my code does show both the button and the mapview.. shouldnt it force close anyways if the problem is the setcontentView?
2) yeah agree with you on this one, though since I couldnt get even this simplest code to work, I didnt really want to overcomplicate it for now.
3) this is not a requirement is it? I mean its a coding convention, a good one yes, but not mandatory..?
4) Will do thanks, I m trying to get my bearings with all the dev websites etc.
PS about the API Key.. is this strictly required for developing on localhost (testing on the emu)? I find the info a bit confusing to be honest..
I will give your mods a shot this evening and will post here later tonight.
For the moment a big thank you for showing me my (silly) mistakes (I kinda miss .NET at times.. I wouldnt have messed up that bad with it..).
thanks!
N
Quick reply:
1) You can only find a view when the content is set. No content: nothin' to find!
3) Just do it! ;-)
API key, localhost? I don't understand your question... I'm on SDK1.1, did some work on the emulator, now most on the G1, no big difference. Don't know about keys. You probably need a key for generation an apk for the market though.
ApiKey
Vlemmix said:
Quick reply:
1) You can only find a view when the content is set. No content: nothin' to find!
3) Just do it! ;-)
API key, localhost? I don't understand your question... I'm on SDK1.1, did some work on the emulator, now most on the G1, no big difference. Don't know about keys. You probably need a key for generation an apk for the market though.
Click to expand...
Click to collapse
Will try and let you know mate!
The API Key you need to put in the xml for the MapView. apparently google has made this a requirement instead of the bogus key. I just dont understand if this is true also for the apps you test on the emu or only the ones that go 'live'..
Vlemmix
HI there,
just wanted to let you know that moving the setcontentview worked a treat!
Im so very embarassed now
thanks again for your help mate, I owe you one.
N
You're welcome, no problem!

[Q] How to insert a "run this always" loop

Hi Everyone,
Using the SkeletonApp default code, how would I insert a void or whatever (sorry not knowing the terminology yet) that would run each cycle of the program like a counter or something?
Just keep it simple, just a "run this always" loop while maintaining the button functions would be great.
thanks and hope you all had a happy thanksgiving
So I added this and it does not work, how in the world do I get a counter working ?
Please, Please someone point me in the right direction?
All I want it to do (in the default SkellyApp) is count to 30, then end the proggy. And yes, I did make the mytimer a variable at the top of my proggy.
public int mytimer;
-------- stuff ---------
@Override
public void onResume() {
mytimer = (mytimer + 1);
if (mytimer == 30) finish();
super.onResume();
}
thank you in advance for taking the time to look, and HOPEFULLY answer this for me.

[Q] How to code a "Really quit?" question when user press Back/Home buttons ?

[Q] How to code a "Really quit?" question when user press Back/Home buttons ?
Hello,
I am a noob ANDROID developer.
(I have a simple problem, I searched the forums and didn't found a solution.)
I am developing a strategy game/wargame on Android.
I am looking for a way to code a "really quit?" routine when the user press the back/home buttons.
(if that happens by mistake now, the whole app starts from scratch on restart)
I've seen tons of code examples, but not for this. I have only one (commercial) app that shows that exact behavior, but no access to that particular source code.
I've fiddle with the onPause(), onRestart(), onStop() , onDestroy() methods, trying to halt the process before exiting, but only got into error messages.
Basically when "back" is pressed I loose my "game screen" instantly. I've also looked into the onBackPressed() method, but then this seems to be an issue between Android 1.5/2.x. I'd like my app to run on both platforms.
Thanks for your help in this matter.
Mmm, as far as I know, you can also try to override the onKeyPressed (don't sure of the name, check the API) and check if the key pressed is back key. I think this is compatible with 1.X
http://android-developers.blogspot.com/2009/12/back-and-other-hard-keys-three-stories.html
Android < 2.0
Code:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// do something on back.
return true;
}
return super.onKeyDown(keyCode, event);
}
Android > 2.0
Code:
@Override
public void onBackPressed() {
// do something on back.
return;
}
If you don't add any code, a back button press will be ignored.
Call finish() method of your running Activity to stop your application.
Deleted post (question already answered)
Thanks!
Here the "quick and dirty" way I did it: User now have to press Back twice to get out!
===
int backPressed=0;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event){
if(keyCode==KeyEvent.KEYCODE_BACK && event.getRepeatCount()==0){
backPressed++;
}
if(backPressed>1){
return super.onKeyDown(keyCode,event);
}
}
return false;
}
===
(Sorry for the indentation, tabs didn't copy..)

[Completed] Android ROM modification help needed

Hi,
I'm playing with a MTK ROM (4.2.2), I have to modify it in various ways, but I'm new to the whole area and I'm taking it one thing at a time. I'd really appreciate any help and advice I can get.
Currently I have to find out how to change the default rotation of the camera image/feed. The device has only one camera, the CameraInfo.orientation value is set to 90 and the image is upside-down. I want to find a way to set it to 270, so it would be ok.
So far I've found this in /frameworks.av.camera/ICameraService.cpp:
Code:
// get information about a camera
virtual status_t getCameraInfo(int cameraId,
struct CameraInfo* cameraInfo) {
Parcel data, reply;
data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
data.writeInt32(cameraId);
remote()->transact(BnCameraService::GET_CAMERA_INFO, data, &reply);
cameraInfo->facing = reply.readInt32();
cameraInfo->orientation = reply.readInt32();
return reply.readInt32();
}
and this in /frameworks/base/core/jni/android_hardware_Camera.cpp:
Code:
static void android_hardware_Camera_getCameraInfo(JNIEnv *env, jobject thiz,
jint cameraId, jobject info_obj)
{
CameraInfo cameraInfo;
status_t rc = Camera::getCameraInfo(cameraId, &cameraInfo);
if (rc != NO_ERROR) {
jniThrowRuntimeException(env, "Fail to get camera info");
return;
}
env->SetIntField(info_obj, fields.facing, cameraInfo.facing);
env->SetIntField(info_obj, fields.orientation, cameraInfo.orientation);
char value[PROPERTY_VALUE_MAX];
property_get("ro.camera.sound.forced", value, "0");
jboolean canDisableShutterSound = (strncmp(value, "0", 2) == 0);
env->SetBooleanField(info_obj, fields.canDisableShutterSound,
canDisableShutterSound);
}
Neither of those are actually the place where the CameraInfo.orientation is being set, which is what I'm looking for. Also I want to find out where can I set the camera to be facing front or back.
Again, I'd really appreciate any pointers you could give me. Thanks!
Chris_M. said:
Hi,
I'm playing with a MTK ROM (4.2.2), I have to modify it in various ways, but I'm new to the whole area and I'm taking it one thing at a time. I'd really appreciate any help and advice I can get.
Currently I have to find out how to change the default rotation of the camera image/feed. The device has only one camera, the CameraInfo.orientation value is set to 90 and the image is upside-down. I want to find a way to set it to 270, so it would be ok.
So far I've found this in /frameworks.av.camera/ICameraService.cpp:
Code:
// get information about a camera
virtual status_t getCameraInfo(int cameraId,
struct CameraInfo* cameraInfo) {
Parcel data, reply;
data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
data.writeInt32(cameraId);
remote()->transact(BnCameraService::GET_CAMERA_INFO, data, &reply);
cameraInfo->facing = reply.readInt32();
cameraInfo->orientation = reply.readInt32();
return reply.readInt32();
}
and this in /frameworks/base/core/jni/android_hardware_Camera.cpp:
Code:
static void android_hardware_Camera_getCameraInfo(JNIEnv *env, jobject thiz,
jint cameraId, jobject info_obj)
{
CameraInfo cameraInfo;
status_t rc = Camera::getCameraInfo(cameraId, &cameraInfo);
if (rc != NO_ERROR) {
jniThrowRuntimeException(env, "Fail to get camera info");
return;
}
env->SetIntField(info_obj, fields.facing, cameraInfo.facing);
env->SetIntField(info_obj, fields.orientation, cameraInfo.orientation);
char value[PROPERTY_VALUE_MAX];
property_get("ro.camera.sound.forced", value, "0");
jboolean canDisableShutterSound = (strncmp(value, "0", 2) == 0);
env->SetBooleanField(info_obj, fields.canDisableShutterSound,
canDisableShutterSound);
}
Neither of those are actually the place where the CameraInfo.orientation is being set, which is what I'm looking for. Also I want to find out where can I set the camera to be facing front or back.
Again, I'd really appreciate any pointers you could give me. Thanks!
Click to expand...
Click to collapse
Hello,
Please refer here [Guide]How To Port & Modify Roms For Mediatek[Everything] and read the entire thread carefully.
If you still run into queries please post in the thread itself, the experts there might be able to assist you.
Regards
Vatsal,
Forum Moderator.
Thanks, Vatsal!
Just to share - in the end I found that all the camera settings are in ../mediatek/custom/mt6572/hal/imgsensor/src/cfg_setting_imgsensor.cpp
Glad you found the fix mate.
Thread closed!

Categories

Resources