[APP] Start / Stop Sense - Windows Mobile Apps and Games

This is 2 really simple apps and it creates 2 shortcuts off the start menu to them.
One to Stop Sense and the other to Start Sense.
(It does not do anything with any other Today Item. Titanium is a Today Item. It will not stop or start Titanium.)
Purpose - Stop Sense does exactly that, which makes more memory available. I see 110 MB available when Sense is not running. I start Sense, and there is 75 MB available. Sense will continue to eat up more memory as you use different tabs. Stopping it and starting it will return alot of this memory.
I attached the source code to post #2.
Icons by Lechux posted here: http://forum.xda-developers.com/showpost.php?p=5887883&postcount=1 as the Firestorm Iconset.
Pointed out to me by Joe Bleau posted here: http://forum.xda-developers.com/showpost.php?p=11197629&postcount=32967
where he gave proper reference to the original and made a 2nd one with the other color.
This app is very simple, but if you find it useful, please thank the post.

Source Code
Attached here is the entire project with source code to build it.
Things that can be learned from the source code
How to use functions defined in core.dll.
How to use PostMessage.
How to write to the registry.
How to write an app with no user interface.
How to create a cab
How to include multiple targets in 1 cab.
If you learn something from this, or find it useful, please thank the post.
File where all the work is done SenseState.cs:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace StopSense_JVH3
{
class SenseState
{
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
[DllImport("coredll.dll")]
private static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
public const int HWND_BROADCAST = 0xffff;
public const int WM_WININICHANGE = 0x001A;
public static void StartSense()
{
try
{
RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Today\Items\HTC Sense", true);
if (RegKey != null)
{
RegKey.SetValue("Enabled", 1);
RegKey.Close();
}
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
catch (Exception someEx)
{
string s = someEx.Message;
int i = 0;
i++;
}
}
public static void StopSense()
{
try
{
RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Today\Items\HTC Sense", true);
if (RegKey != null)
{
RegKey.SetValue("Enabled", 0);
RegKey.Close();
}
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
catch (Exception someEx)
{
string s = someEx.Message;
int i = 0;
i++;
}
}
}
}
Then it is called in Program.cs
Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace StopSense_JVH3
{
class Program
{
static void Main(string[] args)
{
SenseState.StopSense();
}
}
}

Thanks. Would it be hard to add a reset shortcut too?

Reserving Post
Just in case, but the app is so simple I can't imaging a need for this yet.

mwalt2 said:
Thanks. Would it be hard to add a reset shortcut too?
Click to expand...
Click to collapse
There is already a reset shortcut to reset the phone.
And a Sense Reset also already exists.

JVH3 said:
There is already a reset shortcut to reset the phone.
And a Sense Reset also already exists.
Click to expand...
Click to collapse
I know it already exists. I was just thinking it could be an all-in-one solution (start, stop, reset).

Frozen on NRG Splash Screen
I'm sorry to report that I have a spare Titlt 2 that I hard resetted this afternoon to make default Home screen captures for your app, running Energy.RHODIUM.28244.Sense2.5.Cookie.2.0.Feb.01 w/o any mods nor apps except Whip2Snap to make screen captures and w/o SIM.
I installed StartStopSense_JVH3_v1001.CAB while I was in Titanium mode (Sense stopped) & when I clicked on Start Sense, nothing was happening. I restarted the phone for good measure, same results. I then started Sense via Start > Settings > Home > Items and then tried Stop Sense. The phone froze on the splash screen before normally Starting Sense text appears. I soft resetted twice and both times I got: Mainsplash > animation > NRG/HTC Quietly Brilliant > No SIM warning & black dialer (emergency calls only) & after waiting a while, pressing End brings me to the same NRG splash (see screen capture below), never getting to Home. The End hardware button does not bring up Home.
Only Start works but Start > Home does not work. Start > Settings > Remove program StartStopSense_JVH3_v1001.CAB worked but still no Home!
Soft reset: still no Home, stuck on NRG's splash screen and End hardware button does not bring up Home. Only solution I could think of is to hard reset.
If you want to try StartStopSense_JVH3_v1001.CAB, I strongly suggest that you backup your settings & data first.
Edit: Start > Whip2Snap worked so I took this screen capture before hard resetting:

Hard reset was not necessary / source code and full project is in post #2
Joe Bleau said:
I'm sorry to report that I have a spare Titlt 2 that I hard resetted this afternoon to make default Home screen captures for your app, running Energy.RHODIUM.28244.Sense2.5.Cookie.2.0.Feb.01 w/o any mods nor apps except Whip2Snap to make screen captures and w/o SIM.
I installed StartStopSense_JVH3_v1001.CAB while I was in Titanium mode (Sense stopped) & when I clicked on Start Sense, nothing was happening. I restarted the phone for good measure, same results. I then started Sense via Start > Settings > Home > Items and then tried Stop Sense. The phone froze on the splash screen before normally Starting Sense text appears. I soft resetted twice and both times I got: Mainsplash > animation > NRG/HTC Quietly Brilliant > No SIM warning & black dialer (emergency calls only) & after waiting a while, pressing End brings me to the same NRG splash (see screen capture below), never getting to Home. The End hardware button does not bring up Home.
Only Start works but Start > Home does not work. Start > Settings > Remove program StartStopSense_JVH3_v1001.CAB worked but still no Home!
Soft reset: still no Home, stuck on NRG's splash screen and End hardware button does not bring up Home. Only solution I could think of is to hard reset.
If you want to try StartStopSense_JVH3_v1001.CAB, I strongly suggest that you backup your settings & data first.
Edit: Start > Whip2Snap worked so I took this screen capture before hard resetting:
Click to expand...
Click to collapse
The app only stops sense and starts sense.
It does not stop Titanium (Windows Default) and it does not start Titanium.
I have stopped and started sense several times with it.
You realy didn't need to hard reset. I published the source code in post #2.
You can see that all running it does is modify 1 registry entry. Then sends a message using PostMessage so that windows will be notified of the change.
If you would have just used Start->Settings->Today->Items and selected the option that you wanted, you would have been able to correct anything without a hard reset.
Or to just have run Start Sense.
Titanium (Windows Default) is a today plugin. The app does not toggle between Titanium and Sense, it only stops sense and starts sense.
The image you posted is almost exactly what I see when I stop sense.
Then I use the Start Sense app to start sense, and Sense Starts.
Start Sense is not designed to stop any other today items, such as Windows Default, before starting sense.

Idea for new version
Make it more general
New version should be renamed to Stop Today Items / Start Today Items / Start Sense / Start Titanium
Stop Today Items (Biggest Memory Savor)
Stop all today items, such as Sense or Titanium or any others, recording which ones it stopped.
Start Today Items
Stop any running today items.
Start all today items that Stop Today Items had stopped.
Start Sense
Stop all today items. Start Sense.
start Titanium (Saves memory, but it is a today item, so it does consume some.)
Stop all today items. Start Titanium (Windows Default).
I'll need some more icons. Please post pngs.

Start & Stop Sense
I want to thank you JVH3, for your support.
Even being apparently simple, as you wrote, for me it was a pain going all the way through menus to start and stop sense everytime I wanted to play a movie or use GPS.
People like you, Joe Bleau and others, not forgeting NRGZ28, that support this development are the ones that will keep this excelent smartphone alive for a long time.
I have waited a long time to dive into this ROM. I could not afford having issues with my work tool.
I have been following this thread for quite some time and could see all the effort you all put into it.
Last week, reading the posts, I figured out that it was stable enough to flash it in my TP2.
And it really is amazing.
The only issue I had so far is a screen freezing (the phone keeps receiveing calls) when I go inside some configuration menus, like sounds. But I only do that on my spare time.
I did not use TASK29 (I didn´t understand how to use it) I had the original WWE stock ROM that came with it from htc. I bought an unlocked TP2 from Amazon.
Probably when I wipe it all with Task29 this issue disappears. I haven´t read any report with an issue like that.
I´ll keep you posted when I do that.
Thanks again
costinhas.
Brazil.

Possible problem?
Here is all that I did today which led me to my problem:
1. Switched from Panel start menu to Normal start menu
2. Installed MMAppLauncher from here
3. Selected override start menu option in the app above
4. Installed StartStopSense app
Sense is stopped just fine. But when I try to restart it, I get the never ending loop of "Tap here to launch..." and "Launching HTC Sense." A search reveals that this problem might be a common one across different situations. What I don't know is whether its the MMAppLauncher or StartStopSense that is the possible culprit.
Any ideas?

bipinsen said:
Here is all that I did today which led me to my problem:
1. Switched from Panel start menu to Normal start menu
2. Installed MMAppLauncher from here
3. Selected override start menu option in the app above
4. Installed StartStopSense app
Sense is stopped just fine. But when I try to restart it, I get the never ending loop of "Tap here to launch..." and "Launching HTC Sense." A search reveals that this problem might be a common one across different situations. What I don't know is whether its the MMAppLauncher or StartStopSense that is the possible culprit.
Any ideas?
Click to expand...
Click to collapse
This app is not responsible for any sense restart loop.
My guess is that you are using Cookie 2.0 and have the Task widget on your homescreen, but no tasks to display. It's a common problem with Cookie 2.0.
Common fix found in that thread is to:
Stop Sense
add a task through the windows interface to tasks. With an energy ROM: Action->Task
Start Sense
--------------------------------------------
Literally, these app (Start Sense / Stop Sense ) change 1 registry entry when run.
Start Sense does this
[HKLM\Software\Microsoft\Today\Items\HTC Sense]
Enabled=1
Stop Sense does this
[HKLM\Software\Microsoft\Today\Items\HTC Sense]
Enabled=0
After that, each apps does this:
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
That just tells the operating system that something changed. The operating system is responsible for everything beyond that.
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace StopSense_JVH3
{
class SenseState
{
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
[DllImport("coredll.dll")]
private static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
public const int HWND_BROADCAST = 0xffff;
public const int WM_WININICHANGE = 0x001A;
public static void StartSense()
{
try
{
RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Today\Items\HTC Sense", true);
if (RegKey != null)
{
RegKey.SetValue("Enabled", 1);
RegKey.Close();
}
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
catch (Exception someEx)
{
string s = someEx.Message;
int i = 0;
i++;
}
}
public static void StopSense()
{
try
{
RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Today\Items\HTC Sense", true);
if (RegKey != null)
{
RegKey.SetValue("Enabled", 0);
RegKey.Close();
}
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
catch (Exception someEx)
{
string s = someEx.Message;
int i = 0;
i++;
}
}
}
}

JVH3 said:
This app is not responsible for any sense restart loop.
My guess is that you are using Cookie 2.0 and have the Task widget on your homescreen, but no tasks to display. It's a common problem with Cookie 2.0.
Common fix found in that thread is to:
Stop Sense
add a task through the windows interface to tasks. With an energy ROM: Action->Task
Start Sense
--------------------------------------------
Literally, these app (Start Sense / Stop Sense ) change 1 registry entry when run.
Start Sense does this
[HKLM\Software\Microsoft\Today\Items\HTC Sense]
Enabled=1
Stop Sense does this
[HKLM\Software\Microsoft\Today\Items\HTC Sense]
Enabled=0
Click to expand...
Click to collapse
I do have Cookie 2.0, but no Task widgets. A simple soft reset brings Sense back to life. Strange. But thanks for the explanation on what the app does.

Re: What Start/Stop Sense Does
JVH3 said:
The app only stops sense and starts sense.
It does not stop Titanium (Windows Default) and it does not start Titanium...
Click to expand...
Click to collapse
Sorry, I thought the app was for Sense <---> Windows default, hence the icons I suggested in the other thread:
***
Thanks for your reply with details.

Joe Bleau said:
Sorry, I thought the app was for Sense <---> Windows default, hence the icons I suggested in the other thread:
***
Thanks for your reply with details.
Click to expand...
Click to collapse
That was one of the reasons that I went with the other 2 icons.
I have updated post #1 with a little more info, so that no one else will misunderstand.

Next Version Idea
Instead of my previous idea of 4 apps, just 3.
Sense
Titanium
Stop Today Items
I am thinking that number of users that are using Today items other than Sense or Titanium is too small to be concerned with. I don't use them, so I don't have any real motivation to support other today items.
So, unless a hefty donation comes my way requesting support of other today items besides Sense, Titanium, and None, I am not planning to support them.
This gives the ability to switch between them easily and also no today items for maximum available memory.
Sense would stop all today items and then Start Sense
Titanium would stop all today items and then Start Titanium
Stop Today Items would stop all today items.
I am open to names and suggestions.
Maybe Go Sense, Go Titanium, Today Items Off
Or Start Sense, Start Titanium, Stop Today Items
I am a programmer. Names would be deferred to sales marketing where I work, so please post ideas and pngs.
Thinking the current Start Sense icon works, but I would need a similar Titanium and maybe a cross between Titanium and Sense with the red circle.
Anyone with Art or photoshop talent, please post.
128x128 png is the prefered format.
Also, icons can not have muliple levels of transparancy. Either transparent or solid. No translucent.

Name Idea
SST
Stop (or Start) Sense Titanium, (also) Stop (or Start) Some Today's, (plus) Stop Start Today
Another name could be Today All, or Today Terminator. LoL
SST is a lil more universal for what it could stand for and describe as doing.

Related

Need Some Help With Layout/Programming?

Hi all,
Some of you might know I'm currently working my NubDial (http://forum.xda-developers.com/showthread.php?t=629032) during my free time. However, I've run into a bug that I'm quite lost at.
Basically, whenever I long-press the "Menu" button to get the virtual keyboard to display, it messes up my layout. When I press "Back" or long press "Menu" again to hide the virtual keyboard, my layout remains messed up until I exit the app. See attached files for what I'm saying.
My source code is available here: http://code.google.com/p/nubdial
Any help would be greatly appreciated, thank you!
Update:
Anyone knows how to launch Call log and Favourites using Intent?
The following:
Code:
public Intent getCallLogIntent() {
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(android.provider.CallLog.CONTENT_URI);
return i;
}
Works but it launches Dialer instead of Call log -_-. Thanks!
Are you trying to have the android keyboard cover the dialpad or just trying to figure out how to keep the layout from staying messed up after you close the android keyboard?
Only looked for a minute and I'm sure you've tried a lot of things but as for the alignment if you look in finger-layout>main.xml, in the RelativeLayout tag, have you tried changing the android:gravity so that the child table is "prepositioned" if you know what I mean?
JoshHart: I would love to have the keyboard simply cover the layout (similar to default Dialer). Any tips? Thanks for the help!
I'll check out the prepositioned thing later, out now.
On a different note, anyone knows how to launch Call log or Favourites using intent? Thanks
Wysie said:
On a different note, anyone knows how to launch Call log or Favourites using intent? Thanks
Click to expand...
Click to collapse
This seems to work on my Nexus:
Code:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setClassName("com.android.contacts", "com.android.contacts.DialtactsActivity");
i.setType("vnd.android.cursor.dir/calls");
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(i);
Don't know for favorites though, a variation of type might do it, but neither "starred" nor "favorites" worked for me.
illojal: Thanks but I already did that and it worked ! Yeah Favourites is kinda weird.

[Q] How To pull data from a database into a scrollable list?

Hi all,
I'm new to Android development but have been going through countless tutorials. One thing I haven't found a tutorial for is how to take a list of items from a database and put them into a list that a user can scroll through and then select one of them to open up a second screen.
E.g. if I have colors in my database, the screen would simply show all the colors in a list that I can scroll through to find the one I want. When I find the one I want, I can then select it to open up a second layout with the details.
Can anyone direct me to a tutorial or information that might go over this? Or just give me some hints as to what I should search for since my attempts didn't return anything relevant.
Thanks.
Ok, here we go:
First you need to create a layout with at least a ListView, and set it to the current activity using setContentView.
Read some data from your database (I dunno how do this, sorry), and add it to a String array or a List<String> (any of them should work).
Set an ArrayAdapter to the array (or List).
Obtain a reference to your layout ListView using findViewById. Set the ArrayAdapter to that reference.
Your list now is filled
To handle the click events, you'll need declare this method:
Code:
YourListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
//Here the code to handle clicks
//You can use a switch method, using position as variable, to know wich of the items was clicked
}
});
Example
Please use the Q&A Forum for questions &
Read the Forum Rules Ref Posting
Moving to Q&A

How do I add settings to the SharedPreferences or Settings menu?

I want to know how to add something to the settings menu in my application. Or if using JellyBean or ICS how to use the button on the right bottom?
I haven't found anything on this topic yet. Can someone give me a tutorial or example? My application is pretty much finished, this is the only thing I am stuck at .
I noticed that:
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
Click to expand...
Click to collapse
So I went to menu/main.xml
That creates that menu with Settings that leads to no page yet.
How do I open or create a settings page? Do I need to create a new activity and use onClick listener ?
Have you tried developer.android.com? Take a look here http://developer.android.com/guide/topics/ui/menus.html
Sent from a Toasted Devil

Print out more text in application with TextView?

Here is the code:
while (i < 16) {
result.setText("example " + i);
i++;
}
As you can see, in this example, the only result that is going to be printed out for user is "example 15", what I would like to do is to print out all of the examples to user example1, 2 and so on. How can I do that? I have one TextView block in my .xml. How to print out all those "example 1..15" without putting them in one big string.
Mariius said:
How to print out all those "example 1..15" without putting them in one big string.
Click to expand...
Click to collapse
You can't. If you're working only with one TextView, then you need to concatenate all the text you need into a single string.
You can also use a ScrollView instead a single TextView, and attach to it programatically a TextView for each element that you need to show.

[Q] Looking for a way to control android with (code-heavy) custom scripts

Hi,
First time here. Glad to find a place with so many users and activity. I was hoping I could get some general information about a task I am trying to accomplish.
I am looking for a code-heavy way of controlling an android phone with scripts. For example, can you hook your android up to your PC and then control it virtually as if you were doing everything with your finger using scripts?
In my mind I imagine the code would look something like this (this is fake code):
1. var i = 30px;
2. Touch the screen at coordinates x, y;
3. Scroll to cords x, y minus i;
4. Touch the screen at cords x, y;
5. Swipe to cords x + 80, y;
6. Single click cords x, y;
7. if (cords x, y = rgb(0, 0-255,0) { //aka a shade of green
8. var count = count++ }
I can code in several languages including Java, and am just starting out in this so any help would greatly be appreciated.
Thank you
storm3012 said:
Hi,
First time here. Glad to find a place with so many users and activity. I was hoping I could get some general information about a task I am trying to accomplish.
I am looking for a code-heavy way of controlling an android phone with scripts. For example, can you hook your android up to your PC and then control it virtually as if you were doing everything with your finger using scripts?
In my mind I imagine the code would look something like this (this is fake code):
1. var i = 30px;
2. Touch the screen at coordinates x, y;
3. Scroll to cords x, y minus i;
4. Touch the screen at cords x, y;
5. Swipe to cords x + 80, y;
6. Single click cords x, y;
7. if (cords x, y = rgb(0, 0-255,0) { //aka a shade of green
8. var count = count++ }
I can code in several languages including Java, and am just starting out in this so any help would greatly be appreciated.
Thank you
Click to expand...
Click to collapse
After taking a look at what your trying to accomplish I would recommend you take a look at the official Android monkeyrunner API. It's a great starting point for controlling an Android device through external code (Through your computer).
shimp208 said:
After taking a look at what your trying to accomplish I would recommend you take a look at the official Android monkeyrunner API[/URL]. It's a great starting point for controlling an Android device through external code (Through your computer).
Click to expand...
Click to collapse
Thank you! I will read through this API and see how it works. :good:

Categories

Resources