Related
Does anyone have experience using GetThreadTimes() on Smartphone? I have some code that works fine on PPC (pulls thread cpu usage for all threads), but it can only get the usage of threads for the current process on Smartphone. There's no reference to the platforms having different security models. Any clues?
Here is the relevant code being used:
Code:
SetProcPermissions( 0xFFFFFFFF ); // should enable access to other threads
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD, 0);
THREADENTRY32 entry;
entry.dwSize = sizeof(THREADENTRY32);
BOOL more = Thread32First(hSnap, &entry);
while(more) {
GetThreadTimes( (HANDLE) entry.th32ThreadID, &creation, &exit, &kernel, &user);
more = Thread32Next(hSnap, &entry);
}
This snippet works fine on PPC devices, but for Smartphone, the GetThreadTimes() call results in an error code of 6 (ERROR_INVALID_HANDLE).
Any help is GREATLY appreciated. I'm trying to wrap up a project that may be trashed if I cannot get this data.
Thanks in advance,
Jay
To test a vista sidebar gadget here.
I've just created this to give a quick overview of how much of the flext balance you have left. I've only tested it with my flext account so have no idea how it will work on other plans. For this to work you'll need to have an account on "My T-Mobile" and be able to view your bill on there.
Anyone who tries this could you please give some feedback on whether it works for you or not?
hi,
i'm a t-mobile user on vista.
are you going to release your source code?
You can view the source of all installed gadgets here:
C:\Users\USERNAME\AppData\Local\Microsoft\Windows Sidebar\Gadgets\
Good tip, i dind't know that (new to vista)
BUT sorry, I'm not the most trusting of people.
And when it comes to installing a gadget to see its code i'd rather now....
especialy the gadget is designed to log into an important and private account of mine...
can you post your source here, and i'll take a look before i install?
[sorry not to trust you.. and if that app works then its a FANTASTIC idea!]
PHP:
/////////////////////////////////////////////////////////////////////
// getData() - Gets the data from CPW via main page
/////////////////////////////////////////////////////////////////////
function getData()
{
XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
globalURL = "https://www.t-mobile.co.uk/eservice/mtmUserLogin.do?username=" + globalLogon + "&password=" + globalPassword + "&submit=Login"
XMLHttp.onreadystatechange = function()
{
if (XMLHttp.readyState == 4)
{
if (XMLHttp.status == 200)
{
parseData();
}
else
{
document.getElementById("dockedLine1").innerHTML = "Error";
document.getElementById("dockedLine2").innerHTML = "Check";
document.getElementById("dockedLine3").innerHTML = "Settings";
}
}
}
XMLHttp.open("POST", globalURL, true);
//Set the request header so that it's not cached in InternetExplorer
XMLHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
XMLHttp.send(null);
}
function parseData()
{
var Results = XMLHttp.responsetext;
if (Results.match("Please enter a valid username and password"))
{
document.getElementById("dockedLine1").innerHTML = "Wrong Pass";
document.getElementById("dockedLine2").innerHTML = "Or username";
}
else
{
// remaining
subStringFirstPart = Results.indexOf("Remaining:</strong>") + 64;
subStringSecondPart = Results.indexOf("</td>", subStringFirstPart);
remainingbalanace= Results.substring(subStringFirstPart, subStringSecondPart);
// unbilled
subStringFirstPart = Results.indexOf("You have £") + 9;
subStringSecondPart = Results.indexOf("of", subStringFirstPart);
unbilled= Results.substring(subStringFirstPart, subStringSecondPart -1);
// phone number
subStringFirstPart = Results.indexOf("<strong>Mobile number</strong>") + 30;
subStringSecondPart = Results.indexOf("</form>", subStringFirstPart);
phonenumber= Results.substring(subStringFirstPart, subStringSecondPart);
// account number
subStringFirstPart = Results.indexOf("<strong>Account number</strong>") + 31;
subStringSecondPart = Results.indexOf("</form>", subStringFirstPart);
account= Results.substring(subStringFirstPart, subStringSecondPart);
// last bill amount
subStringFirstPart = Results.indexOf("Last Bill") + 63;
subStringSecondPart = Results.indexOf("</td>", subStringFirstPart);
lastbill= Results.substring(subStringFirstPart, subStringSecondPart);
// price plan
subStringFirstPart = Results.indexOf("<strong>Plan</strong>") + 21;
subStringSecondPart = Results.indexOf("</p>", subStringFirstPart);
priceplan= Results.substring(subStringFirstPart, subStringSecondPart);
document.getElementById("dockedLine1").innerHTML = "Allowance: £" + remainingbalanace
document.getElementById("dockedLine2").innerHTML = "Unbilled: " + unbilled
}
and the rest?
there's about 6 or 7 files im not pasting it all here, if you're really that scared don't bother. I'm the biggest gadget developer on the Live Gallery i'm not interested in collecting peoples passwords Ok.
I've looked throught the code and found nothing suspicious to those who may be worried.
I installed it and it works fine, though im not too keen on the colour scheme but thats a minor niggle
Good work!!
Its working fine for me, just told me Im £5 over my allowance - Doh!
Well done,a really useful gadget
Rob
Okay cool, if anyone has any issues please let me know.
aghh, its had a bit of a sh*t fit! (see attatched)
I tried closing the gadget and restarting it and now it sits there for ages saying 'Loading' and then does the same as is in the picture below
edit: I logged onto my t-mobile using IE and then logged off and tried the gadget again, now it's started working again
Did this to me too first time i ran it, but its working now.
Nice app ljames28, Thanks very much.
Works great for me
Not sure on the red colour, T-mob pink or blue maybe?
Great idea! though I am not sure I have ever gone over my £180 flext 35 allowance though
£30 unbilled charges.... damn roaming costs lol
Thanks for taking the time to share it !
When it messes up like it does in that screen shot, that's because it cant get your data for various reasons, maybe you don't have an internet connection or may it couldn't log you in right. In any case try reopening the settings and clicking OK to refresh the gadget.
If anyone wants to make graphics that's fine by me but as you can see they're not my strongpoint!
Edit: New version
With this version i can automatically update it without you having to look on here for updates. Also a bit of error checking and readme link etc
Thanks again. i assume that I simply rename the .zip to .gadget to install it? At least, thats what i had to do
Eh :/ Don't tell me it downloads as .zip? What browser are you using? Are you using a download manager?
ljames28 said:
Eh :/ Don't tell me it downloads as .zip? What browser are you using? Are you using a download manager?
Click to expand...
Click to collapse
Yeah, downloads as a .zip in IE7, no download manager. Don't know why as i can see the file extention isn't a zip when i view the link. No biggy. It's simple enough to rename it.
Thanks again.
How odd, anyone else have this issue? I dont seem to get it.
yeh, .zip here too...gona try it now
Can you make this also for Dutch users (t-mobile Netherlands)
Hi all,
Guys, any tweak/app can turn off BT automatic in Mobile when I turn off the BT Headset????????
Thanx
Same here... onoly different
I was looking for an app that will turn on my headset when I turn on my devices BT.
But either one will work for me.
this site can actually provide 2390473296295825 skins for ****ty apps, 340567345034785 3d ****ty moronisms, but no solutions, probably, for now.
shameful decadence for 600+$ machines users.
and no, i am not moron, i learnt everything i know form this site...
long live HTC, ffs, long live, kill ppc's, yeah.
...???
nothin said:
this site can actually provide 2390473296295825 skins for ****ty apps, 340567345034785 3d ****ty moronisms, but no solutions, probably, for now.
shameful decadence for 600+$ machines users.
and no, i am not moron, i learnt everything i know form this site...
long live HTC, ffs, long live, kill ppc's, yeah.
Click to expand...
Click to collapse
... The ****?!?
I haven't tried this particular feature on "Auto Lock (CSDEVCTRL)" app, but it seems to have automatic BT switch off when headset not connected.
http://forum.xda-developers.com/showthread.php?t=386451
It can be done with mortscript plus an external program to turn off bluetooth (i don't think mortscript can do it all by itself).
Try running this mortscript:
Code:
handsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
lastHfState = 0
While (1)
bluetoothState = RegRead("HKLM", "System\CurrentControlSet\Control\Power\State" , "Bluetooth" )
if(bluetoothState = 1)
lastHfState = handsfreeState
handsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
if(lastHfState = 1 && handsFreeState = 0)
Message("Bt should be turned off now")
endif
endif
Sleep (2000)
EndWhile
Once run, the script will run in background and every two seconds (of course you can change this value) will check if BT is on. If it is, it will check if the handsfree has been disconnected (more precisely, if it was connected during previous pass, AND if it's disconnected now). If it has, the script will display a message box. Of course you need to replace the line:
Code:
Message("Bt should be turned off now")
With code actually launching a program that will turn off BT. The only program capable of this that crosses my mind now is VJVolubilis (www.vijay555.com). A mortscript using it will look like this:
Code:
handsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
lastHfState = 0
While (1)
bluetoothState = RegRead("HKLM", "System\CurrentControlSet\Control\Power\State" , "Bluetooth" )
if(bluetoothState = 1)
lastHfState = handsfreeState
handsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
if(lastHfState = 1 && handsFreeState = 0)
Run("\Program Files\vijay555\VJVolubilis.exe", "-blueoff")
endif
endif
Sleep (1000)
EndWhile
I know that there are other, maybe smaller programs that can turn off BT, but i simply can't remember any of them now.
A note: the only way to stop this script is to kill mortscript.exe process with a taskmanager or soft-reseting your device. And if you want to play around with editing it, make sure to kill the one currently running before running another instance.
And if you're worried about how constantly running mortscript will affect your device's performance - it won't affect it at all I use a similar script than monitors the headphones state and starts MortPlayer if i plug in the headphones. Never noticed any additional CPU load.
nothin said:
this site can actually provide 2390473296295825 skins for ****ty apps, 340567345034785 3d ****ty moronisms, but no solutions, probably, for now.
shameful decadence for 600+$ machines users.
and no, i am not moron, i learnt everything i know form this site...
long live HTC, ffs, long live, kill ppc's, yeah.
Click to expand...
Click to collapse
this place provides TONS of solutions for TONS of stuff... and i too learnt everything i know from this website. considering what you said yourself, it's kind of dumb to say this place is useless.
Sean D. said:
... The ****?!?
Click to expand...
Click to collapse
hahahha, thats exactly wut i said out loud. then i saw u posted wut i just said
mr_deimos said:
It can be done with mortscript plus an external program to turn off bluetooth (i don't think mortscript can do it all by itself).
Try running this mortscript:
Code:
handsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
lastHfState = 0
While (1)
bluetoothState = RegRead("HKLM", "System\CurrentControlSet\Control\Power\State" , "Bluetooth" )
if(bluetoothState = 1)
lastHfState = handsfreeState
handsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
if(lastHfState = 1 && handsFreeState = 0)
Message("Bt should be turned off now")
endif
endif
Sleep (2000)
EndWhile
Once run, the script will run in background and every two seconds (of course you can change this value) will check if BT is on. If it is, it will check if the handsfree has been disconnected (more precisely, if it was connected during previous pass, AND if it's disconnected now). If it has, the script will display a message box. Of course you need to replace the line:
Code:
Message("Bt should be turned off now")
With code actually launching a program that will turn off BT. The only program capable of this that crosses my mind now is VJVolubilis (www.vijay555.com). A mortscript using it will look like this:
Code:
handsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
lastHfState = 0
While (1)
bluetoothState = RegRead("HKLM", "System\CurrentControlSet\Control\Power\State" , "Bluetooth" )
if(bluetoothState = 1)
lastHfState = handsfreeState
handsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
if(lastHfState = 1 && handsFreeState = 0)
Run("\Program Files\vijay555\VJVolubilis.exe", "-blueoff")
endif
endif
Sleep (1000)
EndWhile
I know that there are other, maybe smaller programs that can turn off BT, but i simply can't remember any of them now.
A note: the only way to stop this script is to kill mortscript.exe process with a taskmanager or soft-reseting your device. And if you want to play around with editing it, make sure to kill the one currently running before running another instance.
And if you're worried about how constantly running mortscript will affect your device's performance - it won't affect it at all I use a similar script than monitors the headphones state and starts MortPlayer if i plug in the headphones. Never noticed any additional CPU load.
Click to expand...
Click to collapse
Thank you mr_deimos, appreciate yr tweak n will give it a try
sorry guys, haven't you ever had bad, bad day...
so it was bad one for me..
sorry again.
so, you may remove whole thing related to my whining..
Hey guys, I have an app I'm working on where it will prompt the user for a Name and Email..
When the user hits submit it will then try to collect the data and send it to a PHP script that will then return a JSON array..
I have had this work for so long on Gingerbread Phones (HTC Thunderbolt, Motorola Droid (Milestone), DroidX, Samsung Moment)
However, when I try to use my Motorola Xoom (HoneyComb) for some reason it is getting hung up at HttpResponse..
Code:
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://link.to.my.php.script/");
httppost.setEntity(new UrlEncodedFormEntity(infoValuePairs));
[b]HttpResponse response = httpclient.execute(httppost);[/b] //**Jumps to the catch here!**
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line);
}
is.close();
String result = sb.toString();
JSONArray jArray = new JSONArray(result);
JSONObject json_data = jArray.getJSONObject(0);
sqlName = json_data.getString("name");
sqlEmail = json_data.getString("email");
}
catch(Exception e)
{
setExceptionVerify(e.toString());
}
In the code you can see where I commented where it will jump.. I thought it might have something to do with it being a Wifi-Only Device, but I wasn't sure if there was a special permission for that.. Maybe because android.permissions.INTERNET is only for like 3G/4G etc..
Anyway, here is what I have for permissions in my Manifest file:
Code:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Any help is greatly appreciated guys!
Thanks in advance
Different thread
I had this problem too. Check this link out: <<actually, XDA wont let me post links cuz I'm a new member haha... so just look at the quote below>>
"The network is especially slow and inconsistent, so you should never do network requests on your main thread. In fact, in the upcoming Honeycomb release we’ve made network requests on the main thread a fatal error, unless your app is targeting an API version before Honeycomb. So if you want to get ready for the Honeycomb SDK, make sure you’re never doing network requests on your UI thread. (see “Tips on being smooth” below.)"
Therefore, do all network stuff on a different thread. I would recommend trying an AsyncTask (like the article suggests) and do your network handling there.
<<Sigh.. again, I cant post links >>
Appreciate the input tmpryid..
If you could possibly send me the link in PM that would be awesome.. I knew something was going on and I just wasn't sure..
Thanks again!
Hi,
I wrote an application that gives me the registration id for push notification. I also wrote a server side that sends push notification, but for some reason I am getting id=0:123.... and the notification never sent....
My code is:
void send(string regId)
{
var applicationID = "AIzaSyA-bpa68WzAgRl-ufkhBUAWmg9jTbMZKEo";
var SENDER_ID = "551376547541";
var value = "test";
System.Net.WebRequest tRequest;
tRequest = System.Net.WebRequest.Create("https://android.googleapis.com/gcm/send");
tRequest.Method = "post";
tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8";
tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID));
tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID));
// string postData = "{ 'registration_id': [ '" + regId + "' ], 'data': {'message': '" + txtMsg.Text + "'}}";
string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message=" + value + "&data.time=" + System.DateTime.Now.ToString() + "®istration_id=" + regId + "";
Console.WriteLine(postData);
Byte[] byteArray = Encoding.UTF8.GetBytes(postData);
tRequest.ContentLength = byteArray.Length;
tRequest.ContentType = "application/x-www-form-urlencoded";
System.IO.Stream dataStream = tRequest.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
System.Net.WebResponse tResponse = tRequest.GetResponse();
dataStream = tResponse.GetResponseStream();
System.IO.StreamReader tReader = new System.IO.StreamReader(dataStream);
String sResponseFromServer = tReader.ReadToEnd();
lblStat.Text = sResponseFromServer;
tReader.Close();
dataStream.Close();
tResponse.Close();
}
and I am sending:
send("APA91bH4E4zXOHKCMOON3iy85SJbEPlvtuppF4QOyNh88UqjABM3Mddp8B9kgpvXOZdreBHhz6SpjvYmBPwnWJTgApABqKgr9WB2_Lv8kjFRHZGvVMom0k85wEKsS2qfrMNUMaLBxZA5sNrKE7rMHxGVFUlAmLLvqw");
What do I have to do in order to get the notification in my Android ? What this id means ?
I'm sorry but I can't improve your code, but I do know an alternative:
Parse | Push
It's really easy, I found it two days ago and I'm already loving it
Goodluck with your app
Server Side Code
I have used a the below server side code written in PHP to send data to my client device . make sure your device has a google account and firewall protection of anti virus is disabled . Hope this will help . I will advice to use a real device to test the application or you can you bluestacks virtual device
<?php
// Replace with real server API key from Google APIs
$apiKey = "Your API Key";
// Replace with real client registration IDs
$registrationIDs = array( "Your device registration Id");
// Message to be sent
$message = "Test Notification PHP";
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array( 'price' => $message )
);
$headers = array(
'Authorization: key=' . $apiKey,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
//curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_POST, true);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields ));
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
echo $result;
//print_r($result);
//var_dump($result);
?>
It's unclear from your post which push technology you are using (GCM vs C2DM). Presuming you've opted for GCM (since C2D is deprecated), I've got a working example of both client and server code on Github. I can't post links yet, but it's at github.com/rossja/GCMDemo. Like the prior post, I used PHP for the server side language.
I'm not sure where you're seeing the results you're getting: is that ID contained in the intent extra? Is it something that you're seeing in logcat perhaps?
Please put your code into code tags.
MaartenXDA said:
I'm sorry but I can't improve your code, but I do know an alternative:
Parse | Push
It's really easy, I found it two days ago and I'm already loving it
Goodluck with your app
Click to expand...
Click to collapse
Awesome!I was sick thinking of how to do this and this made it so damn easy!
vijai2011 said:
Awesome!I was sick thinking of how to do this and this made it so damn easy!
Click to expand...
Click to collapse
Yup and you could try the other stuff as well, with the login, users and ParseObjects. It's so easy, I just made a chatroom in 30 minutes .
Sent from my awesome fridge
MaartenXDA said:
Yup and you could try the other stuff as well, with the login, users and ParseObjects. It's so easy, I just made a chatroom in 30 minutes .
Sent from my awesome fridge
Click to expand...
Click to collapse
Chatroom in 30mins? Thats just amazing!
vijai2011 said:
Chatroom in 30mins? Thats just amazing!
Click to expand...
Click to collapse
Yup And you could make something so that the users can send feedback, by just letting them make another ParseObject (e.g "Bugs")
MaartenXDA said:
Yup And you could make something so that the users can send feedback, by just letting them make another ParseObject (e.g "Bugs")
Click to expand...
Click to collapse
Ah...nice .But I have my own code for feedback and reporting fc which sends directly to my mail(along with log for fc) which is better in my case
vijai2011 said:
Ah...nice .But I have my own code for feedback and reporting fc which sends directly to my mail(along with log for fc) which is better in my case
Click to expand...
Click to collapse
Ah yeah that might be better. Although you can also send ParseFiles with Parse