[CODE] Detect the NK.EXE version (6.1 or 6.5) - Windows Mobile

Code:
public static bool IsKernelNative(string NKS000File)
{
int[] pattern = new int[] { 0x0C, 0x00, 0x94, 0xE5, 0x1F, 0x03, 0x50, 0xE3 };
int lookingfor = 0;
using (FileStream input = new FileStream(NKS000File, FileMode.Open, FileAccess.Read))
{
for (int i = 0; i < input.Length; i++)
if (input.ReadByte() == pattern[lookingfor++])
{
if (lookingfor == (pattern.Length - 1))
break;
}
else lookingfor = 0;
}
return (lookingfor == (pattern.Length - 1));
}
Barin will probably be happy to have this (and probably be even happier to replace the code with a File.ReadAllBytes and a LINQ array search if he didn't chose to use NET 2.0 like I did).

very interesting. what does this array (0x0C, 0x00, 0x94, 0xE5, 0x1F, 0x03, 0x50, 0xE3) mean? i.e. what code does it contain? it really can be found in new kernels only.

airxtreme, thanks for the info
But why should i be happy? When i build a rom i know exactly which kernel i use
Anyway i'll add the code to show info about kernel in log window.
PS I don't use .ReadAllBytes method to search a pattern. Sometimes i use it when i need to keep something in memory.
Check your decompiler

l2tp said:
very interesting. what does this array (0x0C, 0x00, 0x94, 0xE5, 0x1F, 0x03, 0x50, 0xE3) mean? i.e. what code does it contain? it really can be found in new kernels only.
Click to expand...
Click to collapse
I don't remember what it exactly does since it's stuff from several months ago but it should be code that is related to the new slots allocation that can be found only on windows mobile 6.5 kernels.
-=Barin=- said:
airxtreme, thanks for the info
But why should i be happy? When i build a rom i know exactly which kernel i use
Anyway i'll add the code to show info about kernel in log window.
Click to expand...
Click to collapse
You certainly do but for first-time users it's not so immediate understanding that each device requires its own native kernel, that the kernel is specifically compiled for the windows mobile version it came with and that even though an old kernel may work on newer windows mobile builds the kitchen needs to know the version of the native kernel to do the proper slots allocation and if it's not chosen correctly the ROM could not work. If you auto-detect the kernel and remove the kernel selection option (that in the case of your kitchen being only labeled WM6.1/WM6.5 I think may confuse users into thinking the option has to do with the windows mobile version rather than the native kernel version) you can remove a considerable burden from beginners.

Related

How to animate images in Mobile ie ::request::

Anyone here know how to write some simple html to animate some web images off a local weather station? I have it working on my desktop written in javascript but mobile ie doesnt seem to want to animate the images. Any help or suggestions will be appreciated.
Why don't you post your HTML and maybe someone can point out what to change to make it work. I have had luck with Javascript and DHTML in PIE so it may be possible to do what you are asking.
sahoopes said:
Why don't you post your HTML and maybe someone can point out what to change to make it work. I have had luck with Javascript and DHTML in PIE so it may be possible to do what you are asking.
Click to expand...
Click to collapse
Code:
<div id="radar">
<noscript><img src="http://xxx.com/xxx.gif" width="1"
height="1" border="0"></noscript>
<SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">
<!--
var c = 9;
/* Preloading images */
var image1 = new Image();
image1.src = "http://xxx.com/1.jpg";
var image2 = new Image();
image2.src = "http://xxx.com/2.jpg";
var image3 = new Image();
image3.src = "http://xxx.com/3.jpg";
var image4 = new Image();
image4.src = "http://xxx.com/4.jpg";
var image5 = new Image();
image5.src = "http://xxx.com/.jpg";
var image6 = new Image();
image6.src = "http://xxx.com/.jpg";
var image7 = new Image();
image7.src = "http://xxx.com/7.jpg";
var image8 = new Image();
image8.src = "http://xxx.com/8.jpg";
var image9 = new Image();
image9.src = "http://xxx.com/9.jpg";
var image10 = new Image();
image10.src = "http://xxx.com/10.jpg";
function disp_img(w)
{
if (c <1)
{
c = 10;
}
var img_src = "http://xxx.com/" + c + ".jpg";
document.ani.src = img_src;
c=c-1;
}
t = setInterval("disp_img(c)", 1000);
//-->
</script>
<IMG SRC="http://xxx.com/10.jpg" BORDER="0" WIDTH="640"
HEIGHT="480" NAME="ani"><br>
</div>
Here is the code that is not working.

Vibration in WM6 Pro

Hey Guys
How can I get access to the vibration function on a device running Windows Mobile 6 Professional, the Vibrate API is not supported (according to MSDN)?
I do basic development in native C++ using Visual Studio using SDKs for WM5 an 6.
Any help will be appreciated!
Code:
#include "stdafx.h"
# include <nled.h>
int GetLedCount()
{
NLED_COUNT_INFO nci;
int wCount = 0;
if(NLedGetDeviceInfo(NLED_COUNT_INFO_ID, (PVOID) &nci))
wCount = (int) nci.cLeds;
return wCount;
}
void SetLedStatus(int wLed, int wStatus)
{
NLED_SETTINGS_INFO nsi;
nsi.LedNum = (INT) wLed;
nsi.OffOnBlink = (INT) wStatus;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &nsi);
}
int _tmain(int argc, _TCHAR* argv[])
{
int count = GetLedCount();
SetLedStatus(1, 1);
Sleep(1000);
SetLedStatus(1, 0);
Sleep(1000);
return 0;
}
You need to test which LED number (int wLed) the device uses. Mostly it is 1.
Thank you MarcLandis, this information help a great deal and works like a charm!

PPTP VPN problem TyphooN CyanogenMod 7 RC2+ v2.7.4 [tytung r7]

Hello,
I have upgraded my HTC HD2 to 2.7.4 CM7 [tytung r7] but now I am having problems with VPN connection which I didn’t have before (2.4.4). It can’t connect already.
Is there any fix about this problem?
Thank you in advance.
anyone whit the same problem ?
Please can someone help me?
I have tried to upgrade to 1VPN but this didn't help me
Same here. Could be Gingerbread related, works just fine with 2.2 builds.
ivangs1 said:
anyone whit the same problem ?
Click to expand...
Click to collapse
I have the same problem with many version of android.I read that a problem is a file ,ppdp,from recompiling.But it seems that only 2 people use the vpn ...
macchese said:
I have the same problem with many version of android.I read that a problem is a file ,ppdp,from recompiling.But it seems that only 2 people use the vpn ...
Click to expand...
Click to collapse
I think this is very important feature because now i can't connect to my office from phone.
Can you send me please a post where the problem with a file ,ppdp is described.
I would try to replace file "/system/bin/pppd" with such from version without this problem.
The other possibility is to search for old version of NAND ROM in which VPN is working and install it, but this will take me a lot of time to downgrade.
ivangs1 said:
I think this is very important feature because now i can't connect to my office from phone.
Can you send me please a post where the problem with a file ,ppdp is described.
I would try to replace file "/system/bin/pppd" with such from version without this problem.
The other possibility is to search for old version of NAND ROM in which VPN is working and install it, but this will take me a lot of time to downgrade.
Click to expand...
Click to collapse
I am writing as evidenced in another post
http://forum.xda-developers.com/showthread.php?t=769026&page=863
It seems like tunnel and session is established but then it gets aborted while creating socket. A similar issue was reported at the end of 2009 but resolved quickly with an update. It was due to a kernel-option which got disabled (see this link: http://code.google.com/p/cyanogenmod.../detail?id=855). Maybe it can give you an idea. The VPN works correctly for instance with Tytung's _r6 kernel.
macchese said:
I am writing as evidenced in another post
http://forum.xda-developers.com/showthread.php?t=769026&page=863
It seems like tunnel and session is established but then it gets aborted while creating socket. A similar issue was reported at the end of 2009 but resolved quickly with an update. It was due to a kernel-option which got disabled (see this link: http://code.google.com/p/cyanogenmod.../detail?id=855). Maybe it can give you an idea. The VPN works correctly for instance with Tytung's _r6 kernel.
Click to expand...
Click to collapse
Thank you for the information.
When i have 2.4.4 with Tytung's _r6 kernel i noticed that PPTP VPN only works correctly with wi-fi connection and was very slow when using 3G connection (in fact it was unusable).
I just saw that the new version of tytung is released - tytung_r8.
I will test latter this week if the problem still exists in new kernel
I have upgraded to v2.8.0-MAGLDR + tytung_r8.1, but still can not connect with PPTP VPN
Can someone else try this.
ivangs1 said:
I have upgraded to v2.8.0-MAGLDR + tytung_r8.1, but still can not connect with PPTP VPN
Can someone else try this.
Click to expand...
Click to collapse
I installed TyphooN CyanogenMod 7 RC2+ v2.8.1[2.3.3][A2SD][tytung r8.1] and does not work. It's a kernel Tytung problem.With this,Incredible Sense v1.0 - CAM FIXED! [HTC Vivo][K:Raf1.9OC],it's all ok.In the forum are the only ones who use the vpn and not angry bird ....
am in the same sh**
I'm using this ROM since a while, and each time I update hoping that the VPN issue would be solved but it doesn't
I posted a couple of times asking about VPN issue but never got an answer from "tyween"...which is surprising!! cz I see him answering all the posts in the thread better than any other Developer on XDAm but it seems he hates VPN
wbsoul said:
I'm using this ROM since a while, and each time I update hoping that the VPN issue would be solved but it doesn't
I posted a couple of times asking about VPN issue but never got an answer from "tyween"...which is surprising!! cz I see him answering all the posts in the thread better than any other Developer on XDAm but it seems he hates VPN
Click to expand...
Click to collapse
I am also badly surprised than nobody answers the questions about VPN (including Google).
Did someone have tried to configure Open VPN and test it ?
I will try this but i first must to get SSL certificate.
Installed TyphooN CyanogenMod 7 RC2+ v2.8.2, replaced kernel with Rafpigna's 1.9 OC GB, but still a no go
i have the same problem,i installed typhoon 2.81,vpn is not work,it's important for me.but nexushd gingerbread 2.3 or 2.4 works well,i don't know how about 2.5.
Now i have this,NexusHD2-Gingerbread V2.5 [Android2.3.3][Kernel: tytung_r8.3],and VPN PPTP works fine.
macchese said:
Now i have this,NexusHD2-Gingerbread V2.5 [Android2.3.3][Kernel: tytung_r8.3],and VPN PPTP works fine.
Click to expand...
Click to collapse
May be the problem is solved in kernel tytung_r8.3.
I should test it with TyphooN ROM.
Nope, VPN wont work. With alocat I see lines like --> I/mtpd Creating PPPoX Socket and then F/mtpd Socket() Protocol not supported ??
lines from pptp.c -->
...
static int create_pppox()
{
int pppox;
log_print(INFO, "Creating PPPoX socket");
pppox = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OPNS);
if (pppox == -1) {
] log_print(FATAL, "Socket() %s", strerror(errno));
exit(SYSTEM_ERROR);
} else {
struct sockaddr_pppopns address = {
.sa_family = AF_PPPOX,
.sa_protocol = PX_PROTO_OPNS,
.tcp_socket = the_socket,
.local = local,
.remote = remote,
};
if (connect(pppox, (struct sockaddr *)&address, sizeof(address)) != 0) {
log_print(FATAL, "Connect() %s", strerror(errno));
exit(SYSTEM_ERROR);
}
}
return pppox;
}
malaa said:
Nope, VPN wont work. With alocat I see lines like --> I/mtpd Creating PPPoX Socket and then F/mtpd Socket() Protocol not supported ??
lines from pptp.c -->
...
static int create_pppox()
{
int pppox;
log_print(INFO, "Creating PPPoX socket");
pppox = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OPNS);
if (pppox == -1) {
] log_print(FATAL, "Socket() %s", strerror(errno));
exit(SYSTEM_ERROR);
} else {
struct sockaddr_pppopns address = {
.sa_family = AF_PPPOX,
.sa_protocol = PX_PROTO_OPNS,
.tcp_socket = the_socket,
.local = local,
.remote = remote,
};
if (connect(pppox, (struct sockaddr *)&address, sizeof(address)) != 0) {
log_print(FATAL, "Connect() %s", strerror(errno));
exit(SYSTEM_ERROR);
}
}
return pppox;
}
Click to expand...
Click to collapse
Do know who can help to solve this problem ?

[Q] File "st" downloads by itself .....

Hey,
So I've just noticed my Nexus 4 running CM 10.2 seems to automatically download a file named "st", I think just about everytime I go to yahoo answers, after the file downloads my phone reboots.
I pasted the content of said file below .... can ANYBODY tell me wtf this is or why its downloading it?
Thank Yall!
HTML:
<html><head></head><body><script type="text/javascript">/* All portions of this software are copyright (c) 2003-2006 Right Media*/var rm_ban_flash=0;var rm_url="";var rm_pop_frequency=0;var rm_pop_id=0;var rm_pop_times=0;var rm_pop_nofreqcap=0;var rm_passback=0;var rm_tag_type="";var rm_enable_supply_transparency=0;var rm_st_referrer="";var rm_md_purl_det_top=0;var rm_md_purl_det_if=0;var rm_md_purl_det_nif=0;var rm_enable_ck_mp=0;var rm_ck_mp_cu="";rm_enable_supply_transparency = 0; rm_st_referrer = "http://answers.yahoo.com/question/index?qid=20121015092323AAaicj9"; rm_md_purl_det_top = "1"; rm_md_purl_det_if = "2"; rm_md_purl_det_nif = "3"; rm_enable_ck_mp = 0; rm_tag_type = "iframe"; rm_url = "http://ad.yieldmanager.com/imp?Z=300x50&cb=1378955811.398703&x=http%3A%2F%2Fclicks%2Ebeap%2Ebc%2Eyahoo%2Ecom%2Fyc%2FYnY9MS4wLjAmYnM9KDE1djVmZ29ubihnaWQkMFo3M1FqazRMakU4Rk1wdlVpejhPZ0I4TmpZdU1sSXhNaVBfampXSSxzdCQxMzc4OTU1ODExMzcxOTY3LHNpJDQ5MDI1NTEsc3AkOTU0MDA2NzY2LGNyJDM2NjU5MzUwNTEsdiQyLjAsYWlkJHNJNFUuV0tMNEhVLSxjdCQyNSx5YngkRXR2aVhSWE00N3MyRUl0Q3hyWWt3USxiaSQxNzk0MzE4NTUxLHIkMSxyZCQxNmllMTV0YWIpKQ%2F2%2F%2Ahttp%3A%2F%2Fglobal%2Eard%2Eyahoo%2Ecom%2FSIG%3D15j408i6d%2FM%3D999999%2E999999%2E999999%2E999999%2FD%3Dmobile%2FS%3D954006766%3AWP%2FY%3DYAHOO%2FEXP%3D1378963011%2FL%3D0Z73Qjk4LjE8FMpvUiz8OgB8NjYuMlIxMiP%5FjjWI%2FB%3DsI4U%2EWKL4HU%2D%2FJ%3D1378955811398703%2FK%3DGM4UO%5FjkBYEW4EvomQxI8Q%2FA%3D7540457405187064449%2FR%3D1%2FX%3D6%2F%2A%24&u=&P=pri%3ayahoo_mobile_us_web%3bsec%3ayahoo%3bcrr%3aUS-UNKNOWN%3b%7C0Z73Qjk4LjE8FMpvUiz8OgB8NjYuMlIxMiP_jjWI%7C954006766%7CWP%7C1378955811.398703&S=2658015051&i=1542970&D=smpv%3D3%26ed%3DzAomdEK4k1NDvJ5__oyLCdlumPoxa3FYwZ0cRfRJq0aHrw--&T=3&_salt=2529253075";var RM_POP_COOKIE_NAME='ym_pop_freq';var RM_INT_COOKIE_NAME='ym_int_freq';if(!window.rm_crex_data){rm_crex_data=new Array();}if(rm_passback==0){rm_pb_data=new Array();if(rm_crex_data.length>0){rm_url+="&X=";for(var i=0;i<rm_crex_data.length;i++){rm_url+=rm_crex_data[i];if(i!=rm_crex_data.length-1){rm_url+=",";}}}}else{rm_pb_data.push(rm_crex_data.pop());rm_url+="&X=";for(var i=0;i<rm_pb_data.length;i++){rm_url+=rm_pb_data[i];if(i!=rm_pb_data.length-1){rm_url+=",";}}rm_url+="&Y=pb";}var flash=new Object();flash=flashDetection();if(cookiesEnabled()){rm_url+=(flash.installed?"&B=10":"&B=12");}else{rm_url+=(flash.installed?"&B=11":"&B=13");}if(!flash.installed||rm_ban_flash==1){rm_url+="&m=2";}if(rm_url.indexOf("&u=")==-1){var url='';try{if(rm_tag_type=="ad"){if(top==self){url=encodeURIComponent(top.location.href);url=url.substr(0,256);rm_url+="&u="+url;}}else if(rm_tag_type=="iframe"){url=encodeURIComponent(document.referrer);url=url.substr(0,256);rm_url+="&u="+url;}}catch(e){}}if(top==self){rm_url+="&r=1";}else{rm_url+="&r=0";}if(rm_enable_supply_transparency==true){var durl='';if(top==window){durl=encodeURIComponent(top.location.href);durl=durl.substr(0,256);rm_url+="&H="+durl;rm_url+="&M="+rm_md_purl_det_top;}else if(top==window.parent){durl=encodeURIComponent(rm_st_referrer);durl=durl.substr(0,256);rm_url+="&H="+durl;rm_url+="&M="+rm_md_purl_det_if;}else{durl=encodeURIComponent(rm_st_referrer);durl=durl.substr(0,256);rm_url+="&H="+durl;rm_url+="&M="+rm_md_purl_det_nif;}}var rm_tag_src="";if(rm_enable_ck_mp==true){rm_tag_src+='<SCRIPT TYPE="text/javascript" SRC="'+rm_url+'"><\/SCRIPT><SCRIPT TYPE="text/javascript" SRC="'+rm_ck_mp_cu+'" ><\/SCRIPT>';}else{rm_tag_src+='<SCRIPT TYPE="text/javascript" SRC="'+rm_url+'"><\/SCRIPT>';}if(rm_pop_frequency){if(rmCanShowPop(rm_pop_id,rm_pop_times,rm_pop_frequency)||rm_pop_nofreqcap){document.write(rm_tag_src);}}else{document.write(rm_tag_src);}function cookiesEnabled(){var cookieEnabled=(navigator.cookieEnabled)?true:false;if(typeof navigator.cookieEnabled=="undefined"&&!cookieEnabled){document.cookie="testcookie";cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)?true:false;}return cookieEnabled;}function rmGetCookie(Name){var search=Name+"=";var CookieString=document.cookie;var result=null;if(CookieString.length>0){offset=CookieString.indexOf(search);if(offset!=-1){offset+=search.length;end=CookieString.indexOf(";",offset);if(end==-1){end=CookieString.length;}result=unescape(CookieString.substring(offset,end));}}return result;}function flashDetection(){var flash=new Object();flash.installed=false;flash.version='0.0';if(navigator.plugins&&navigator.plugins.length){for(x=0;x<navigator.plugins.length;x++){if(navigator.plugins[x].name.indexOf('Shockwave Flash')!=-1){flash.version=navigator.plugins[x].description.split('Shockwave Flash ')[1];flash.installed=true;break;}}}else if(window.ActiveXObject){for(x=2;x<10;x++){try{oFlash=eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+x+"');");if(oFlash){flash.installed=true;flash.version=x+'.0';}}catch(e){}}}return flash;}function rmReplace(myString,toReplace,replaceBy){return(myString.replace(new RegExp(toReplace,'gi'),replaceBy));}function writeCookie(ckName,ckVal){var numdays=14;var today=new Date();var expires=new Date();expires.setTime(today.getTime()+(1000*60*60*24*numdays));var cookieText=ckName+"="+ckVal+";expires="+expires.toGMTString()+";path=/;";document.cookie=cookieText;return null;}function rmCanShowPop(rm_pop_id,pop_times,pop_frequency){var countCookieName=RM_POP_COOKIE_NAME+rm_pop_id;var expireCookieName=RM_POP_COOKIE_NAME+"_expiration"+rm_pop_id;var shownTimes=rmGetCookie(countCookieName);if(shownTimes==null){rmWriteExpirationCookie(expireCookieName,pop_frequency);shownTimes=0;}else{shownTimes=Number(shownTimes);}if(shownTimes<pop_times){shownTimes=1+shownTimes;var expiration=rmGetCookie(expireCookieName);rmWritePopFrequencyCookie(rm_pop_id,shownTimes,expiration);return_value=true;}else{return_value=false;}return return_value;}function rmWritePopFrequencyCookie(rm_pop_id,shownTimes,expiration){var cookieName=RM_POP_COOKIE_NAME+rm_pop_id;var cookieText=cookieName+"="+shownTimes+";"+"expires="+expiration+";path=/;";document.cookie=cookieText;}function rmWriteExpirationCookie(cookieName,frequency){var today=new Date();var expires=new Date();expires.setTime(today.getTime()+(1000*frequency));var cookieText=cookieName+"="+expires.toGMTString()+";"+"expires="+expires.toGMTString()+";path=/;";document.cookie=cookieText;}</script><noscript><img border="0" src="http://ad.yieldmanager.com/imp?Z=300x50&cb=1378955811.398703&x=http%3A%2F%2Fclicks%2Ebeap%2Ebc%2Eyahoo%2Ecom%2Fyc%2FYnY9MS4wLjAmYnM9KDE1djVmZ29ubihnaWQkMFo3M1FqazRMakU4Rk1wdlVpejhPZ0I4TmpZdU1sSXhNaVBfampXSSxzdCQxMzc4OTU1ODExMzcxOTY3LHNpJDQ5MDI1NTEsc3AkOTU0MDA2NzY2LGNyJDM2NjU5MzUwNTEsdiQyLjAsYWlkJHNJNFUuV0tMNEhVLSxjdCQyNSx5YngkRXR2aVhSWE00N3MyRUl0Q3hyWWt3USxiaSQxNzk0MzE4NTUxLHIkMSxyZCQxNmllMTV0YWIpKQ%2F2%2F%2Ahttp%3A%2F%2Fglobal%2Eard%2Eyahoo%2Ecom%2FSIG%3D15j408i6d%2FM%3D999999%2E999999%2E999999%2E999999%2FD%3Dmobile%2FS%3D954006766%3AWP%2FY%3DYAHOO%2FEXP%3D1378963011%2FL%3D0Z73Qjk4LjE8FMpvUiz8OgB8NjYuMlIxMiP%5FjjWI%2FB%3DsI4U%2EWKL4HU%2D%2FJ%3D1378955811398703%2FK%3DGM4UO%5FjkBYEW4EvomQxI8Q%2FA%3D7540457405187064449%2FR%3D1%2FX%3D6%2F%2A%24&u=&P=pri%3ayahoo_mobile_us_web%3bsec%3ayahoo%3bcrr%3aUS-UNKNOWN%3b%7C0Z73Qjk4LjE8FMpvUiz8OgB8NjYuMlIxMiP_jjWI%7C954006766%7CWP%7C1378955811.398703&S=2658015051&i=1542970&D=smpv%3D3%26ed%3DzAomdEK4k1NDvJ5__oyLCdlumPoxa3FYwZ0cRfRJq0aHrw--&T=3&_salt=2529253075&t=2"></img></noscript></body></html>
So you guys know as much about this as me, huh?
thatguy188 said:
So you guys know as much about this as me, huh?
Click to expand...
Click to collapse
I'm on to something.... This file only downloads if I'm on a yahoo answers website on chrome or chrome beta...
Edit: Uninstalling Adaway /ad blocker seems to have stopped it from downloading on yahoo answeres/yahoo ads websites
Why do you have 2 threads with the exact same question?
http://forum.xda-developers.com/showthread.php?t=2445889
I guess you really are... "that guy" lol

[Q] rpoblems with the on click listner :(

hi guys im trying to set an app to have a send sms function to non changing phone number for " opening a service call" thingy for users that have warranty on some electric product that they have bought but i got some problem i wish one of you can help heres the info :
this is the XML :
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textsms"
android:layout_marginTop="94dp"
android:hint="fill in the problem and location and cellphone number"
android:layout_below="@+id/textView3"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="send service request"
android:id="@+id/buttonSms"
android:layout_marginTop="121dp"
android:layout_below="@+id/textsms"
android:layout_centerHorizontal="true"
androidnClick="smsClick"/>
this is the java:
//smssending
Button buttonSms;
EditText textsms;
buttonSms = (Button) findViewById(R.id.buttonSms);
textsms = (EditText) findViewById(R.id.textsms);
final String editPhoneNum = "052444444";
buttonSms.setOnClickListener (new OnClickListener()
{
public void smsClick(View v) {
String phoneNo = editPhoneNum;
String sms = textsms.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}
);
To access variables inside a so-called anonymous inner class like your OnClickListener, they must be declared final. So you must declare textsms like this: final EditText textsms = findViewById(R.id.textsms);
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0
first of all thanks but i did it and i got this now in attachment
never mind guys i just needed to change the method name to onClick thats all
by the way use that code if you wanna make your app send sms to perment number that user cant see like if he order a resturant reservasion or stuff like that
ggggguy said:
never mind guys i just needed to change the method name to onClick thats all
by the way use that code if you wanna make your app send sms to perment number that user cant see like if he order a resturant reservasion or stuff like that
Click to expand...
Click to collapse
Oh i didn't even realize it had another name [emoji14]
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0
Masrepus said:
To access variables inside a so-called anonymous inner class like your OnClickListener, they must be declared final. So you must declare textsms like this: final EditText textsms = findViewById(R.id.textsms);
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0
Click to expand...
Click to collapse
:good:
I think so.You must declear like "final EditText textsms;"
---------- Post added at 08:58 AM ---------- Previous post was at 08:53 AM ----------
ggggguy said:
never mind guys i just needed to change the method name to onClick thats all
by the way use that code if you wanna make your app send sms to perment number that user cant see like if he order a resturant reservasion or stuff like that
Click to expand...
Click to collapse
Android Studio can generate onClick() ,why don't you let IDE to do this job?
smsClick() is bad.

Categories

Resources