[Q] findpreference() returns null - Android Software Development

hxxp://pastebin.ws/g7nrcg
I have a slider (m_sbCur) that I want to be set to disabled when the autocrop button is unticked. findPreference() works fine when done not in onContentChange(). ie. If I tick the checkbox and reopen the settings view the slider is disabled fine. Yet when I add in onContentChange() it throws exception when trying to load the settings as findpreference() is returning null.
Why is it returning null when it works fine not using onContentChange()?

Related

assign Pop up menu to soft key (windows mobile 5 - smartphone)

I needed to change the text and display a pop up menu for the right soft key on the homescreen. This needs to be done when the our plug-in is selected.
I have tried out various implementation none of them worked or were feasible
>> use SHCreateMenuBar on the desktop window and create the required menu bar in resource. But the problem was that I couldn't revert back to the original menu bar when the focus was passed on to the next plug-in.
>> use SHCMBM_SETSUBMENU. sending this message to the menu bar (HWND) handle with the command id of the right soft key and the handle to the pop up menu did not change anything. I also tried to get the actual HMENU handle to the menu bar using SHCMBM_GETMENU
HMENU hmenu = (HMENU)SendMessage(hMenuBar, SHCMBM_GETMENU, 0, 0);
return NULL and GetLastError() returns 5 (Access is denied).
Also tried a variation with the SHCMBM_GETSUBMENU message
HMENU hmenu = (HMENU)SendMessage(hMenuBar, SHCMBM_GETSUBMENU, 0, commandid);
This returns the same result as above.
Something related to this can be found at
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1362079&SiteID=1
If you are wondering if this is possible you can try out the google homescreen plug-in for smartphone which does exactly that.
http://www.downloadsquad.com/2008/03/20/google-launches-today-plugin-for-windows-mobile/
They change the right soft key to display a pop up menu when the plug-in is in focus dynamically. The default "Contacts" button does not have any pop-up.
Waiting.

Windows Mobile: Soft keys in tab control

Hello out there,
I have following problem under Windows Mobile: in need to create a dialog with OK and Cancel button that contains a tab control with several tabs. The trouble is: when the focus is on an edit control that is child of one of the tabs, the mobile phones soft keys, that should control that dialog's OK and Cancel buttons, do not work any more.
I guess, the problem is, that the edit control is not direct child of the dialog, but child of the current tab, that itself is child of the dialog. So, the child -> parent relation is:
edit control -> current tab -> dialog
and the soft keys would only work properly if the edit control was direct child of dialog window, like this:
edit control -> dialog
I already tried to solve the problem by re-directing windows messages the tab's window procedure receives from edit control to dialog window, but this does not work, because the tab's window procedure only receives WM_GETTEXT messages from edit control, no WM_COMMAND messages.
I also tried to provide a customized window procedure for the edit control by SetWindowLong():
Code:
SetWindowLong(hEdit, GWL_WNDPROC, newEditWndProc);
to program edit control to send WM_COMMAND message when WM_KEYDOWN is received and key was soft key, but this results in incorrect depiction of edit control in GUI.
So what can I do?
Concerning the customized edit control window procedure I found a solution: to prevent incorrect graphical depiction, one must not directly call the edit control's default window procedure in customized procedure, but instead use CallWindowProc() indicating address of default window procedure:
Code:
LRESULT CALLBACK customEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
// wrong:
// return defaultEditWndProc(hwnd, msg, wParam, lParam);
// correct:
return CallWindowProc(defaultEditWndProc, hwnd, msg, wParam, lParam);
}
There's another solution that is more nice: in Visual Studio's resource editor, in the dialog resource for each tab page, one can set a property "Style". Setting this to "child" (I guess this would be the English title, my VS displays the Style names in German), solves all the depicted problems, without any dirty hacking in edit control's window procedure
However, there's still something not very nice: the look of the tab page borders. They have 3D-edges, as is typical for Desktop PC Windows. However, any other application under Windows Mobile using tab pages (e.g. Start -> Settings) has a flat edge tab page style. How can I activate this? Is it maybe only available in .NET development?
To make clearer what I'm talking about: have a look on this screenshot:
http://www.brighthub.com/bh_control...owse and apply your theme&postId=23468&page=1
I would like to have a tab page header style like the "Tabs", "Appearance", "Tweaks" and so on tab headers on the screenshot have.

[Q] Tasker : issue with two profiles

Hi
I followed two profiles description :
- This one in order to make autosync on/off automatically : the thing is that I am not able to move the task as an exit task as soon as I set up the timing ; If I do it before, it will be changed to an enter task ; any idea how to have such a behaviour ?
-Autosleep with exceptions : it works but... not for the first call "emergency" call : if I call from an authorized phone, it will switch on the ringtone but it will not change the current ringtone, only for the next call
How could it work ?
As I do not know if it is SGS2 specific or common behaviour, I post it here
Thanks for your help
szdavid said:
This one in order to make autosync on/off automatically[/URL] : the thing is that I am not able to move the task as an exit task as soon as I set up the timing ; If I do it before, it will be changed to an enter task ; any idea how to have such a behaviour ?
Click to expand...
Click to collapse
I prefer to create variables.
On the enter task of the hourly context, set %MYSYNC = 1. Do nothing else. FYI, it's not necessary to name the variable %MYSYNC.
Then create a new profile with the context Variable Set (%MYSYNC = 1). Then create a task that:
1.) Starts Sync
2.) Waits
3.) Stops Sync
4.) Sets %MYSYNC = 0
Thank you ; It seems to work for this profile :
now let's find a solution for the "exception ringtone while in silent mode"

[Q] how to set default home application?

I want to set default home application when user click my menu.
So, I make this code and resolveractivity is shown when I click my menu.
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
intent.setComponent(new ComponentName("android","com.android.internal.app.ResolverActivity"));
startActivity(intent);
But, although I choose any applications in the resolver activity, default application isn't applied.
Why default home application isn't changed?

Android-"Complete Action Using" Ignoring input - What am I doing wrong?

So I'm a noob when comes to android programing. Can someone tell me if the "Complete Action Using" dialog box is suppose to set the defaults when you use the "Always" response? Personally I thought it was however in my programming I have not been able to get it to use the "always" response always. What I mean is if I have "Google Music" installed and then I want to kick off the music player i ALWAYS get the "Complete Action Using" dialog popup.
To remove my code I went back to the Android developers first app program and used that. The SendMessage code now looks like this below. When running this on the emulator the "Complete Action Using" popup always comes up irrespective of selecting "Always" or "Just Once". What have I missed or done wrong?
Code:
public void sendMessage(View view) {
// Do something in response to button
if(android.os.Build.VERSION.SDK_INT>=15){
Intent intent=Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
Intent.CATEGORY_APP_MUSIC);
startActivity(intent);
}else{
Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");//Min SDK 8 and deprecated in API 17 for makeMainSelectoryActivity
startActivity(intent);
}
}
tommiyau said:
So I'm a noob when comes to android programing. Can someone tell me if the "Complete Action Using" dialog box is suppose to set the defaults when you use the "Always" response? Personally I thought it was however in my programming I have not been able to get it to use the "always" response always. What I mean is if I have "Google Music" installed and then I want to kick off the music player i ALWAYS get the "Complete Action Using" dialog popup.
To remove my code I went back to the Android developers first app program and used that. The SendMessage code now looks like this below. When running this on the emulator the "Complete Action Using" popup always comes up irrespective of selecting "Always" or "Just Once". What have I missed or done wrong?
Code:
public void sendMessage(View view) {
// Do something in response to button
if(android.os.Build.VERSION.SDK_INT>=15){
Intent intent=Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
Intent.CATEGORY_APP_MUSIC);
startActivity(intent);
}else{
Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");//Min SDK 8 and deprecated in API 17 for makeMainSelectoryActivity
startActivity(intent);
}
}
Click to expand...
Click to collapse
If you select "Always", the default application will be set which you can remove from the settings.
However, there should be a better possibility to do this.
You could try to use the unofficial Google Music API.
EDIT: If you just want to start Google Music use that code:
Code:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address"); //replace the package name
startActivity(LaunchIntent);
nikwen said:
If you select "Always", the default application will be set which you can remove from the settings.
However, there should be a better possibility to do this.
You could try to use the unofficial Google Music API.
EDIT: If you just want to start Google Music use that code:
Code:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address"); //replace the package name
startActivity(LaunchIntent);
Click to expand...
Click to collapse
Actually you can not use this to set a default application. You can try this in the emulator. The selection of Always does not impact the default application setting.
It appears that the Confirmation of "Always" and "Just Once" when ACTION_MAIN is used with a CATEGORY is a misnormer altogether. A default is only set when an Intent contains a mime type. So if you did not use ACTION_MAIN but say GET_CONTENT with a type of audio/* then you can launch with a default player.
Try it your self in the emulator this never sets a default. Seems everyone says it does but certainly the emulator and a real device support the outcomes that a default is never established through his call at all.
Stll looking for a answer but at least I now know that the above will always prompt you to select an application irrespective of any defaults set.
did you try it on a device?
out of ideas said:
did you try it on a device?
Click to expand...
Click to collapse
you mean my original code. Yes I did and the way it behaves is as described. I also went debugging what the makemainselector actually does under these situations. It actually registers the selected application in the packagemanager against the "Android device". Subsequent calls with the APP_MUSIC Category do not get found for some reason. Its like the code does not look for the application that is registered but asks for the number of applications that support the category and then throws a prompt rather than checking if there is a existing default. So either the makemainselector is the wrong thing to use or this just behaves incorrectly. When looking through the developer apps it does state to use makemainselectoractivity for API>15 as the action for the <15 intent of MUSIC_PLAYER is deprecated. However, an intent using MUSIC_PLAYER works corrctly and kicks off the default where as makemainselectoractivity seems to set the default, and kick off the app but does this every time. So either the documentation is incorrect or the code has a bug. If I get time I'll try and look through the code but at present it does not seem that this actually works to select a default allocated application and use it......you have to put up with being prompted and then selecting an option or double clicking every time.
Code:
Intent intent=Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
Intent.CATEGORY_APP_MUSIC);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//Min SDK 15
PackageManager pm = this.getPackageManager();
final ResolveInfo mInfo = pm.resolveActivity(intent, 0);
Toast.makeText(this, pm.getApplicationLabel(mInfo.activityInfo.applicationInfo), Toast.LENGTH_LONG).show();
startActivity(intent);

Categories

Resources