Related
Hi Guys,
I'm going through the forum, I'm new to embedded developement, I've been able to do my first MessageBox("Hello World") in C using VS2005.
I want to understand how all this works, like :
- Accessing any "mass storage" device ? (the root FS ?, /, c:\, whatevername )
- Dumping the whole registry + values.
- Logging Process and activity even while "device locked" (new process, etc..)
And having more knownledge about the internals and devices, booting etc..
I'm kind of lost and my embedded knowledge is very thin..
The PPC i have is running WM5 on QTEK9100 (SPVM3000)..
Any pointers, posts, sources, small explication are more than welcome...
Hope you can help,
Regards,
r.
Welcome!
Wow those sure are some heavy requests for someone who is just starting.
How much experience do you have with C and Win32 APIs?
To start you off here is an excellent site for Windows Mobile programming tips and tricks:
www.pocketpcdn.com
Couple more pointers:
Device root is "\", no drives (SD cards mounted as folders) kind of like Linux.
All path are absolute - no ".\" or ".."
You can use standard C or Win32 functions for file operations.
Registry functions are also same as Desktop windows except you have to use the "Ex" version of of the function.
Example:
RegOpenKey - not implemented, use RegOpenKeyEx.
For process lists etc, google for ToolHelp32.
Thanks,
I'm at ease w/ ANSI C, have some familiarity w/ Win32 APIs,
but as far as I'm seeing I'm trying to code on Win32 Intel First,
then i try to "port" it to PocketPC Mobile, sometime it works
sometime functions doesn't even exists... MSDN doesn't seems very consistent over Win32 vs WM, but as I'm new I guess i'm missing a lot..
WinMain() prototype changes according to your target...otherwise
VS2005 yell about Overloading WinMain, It is VERY annnoying..anyway
Thanks for the links and the *Ex trick, I'll try to get deeper with this.
I have a strange problem trying to do my Own MessageBoxPrintf:
int MessageBoxPrintf(int, const char * title, const char * fmt, ...)
{
va_list ap;
char * buffer = NULL;
/* formatting and fixed size yes...*/
buffer = (char *) malloc (1024 * sizeof(char));
if (!buffer)
return -1;
memset(buffer, 0, 1024);
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
va_end(ap);
MessageBox(NULL, (LPCWSTR)buffer, (LPCWSTR)title, type);
return 0;
}
It does compile, but it display craps, since there is no stderr,stdout,stdin and
that I'm mostly coding on Win32/VMware, I don't know how to debug on my PPC (no USB connection), and I have no idea what's wrong.. it might be obvious, but it's late..
As I don't know what LPCWSTR stand for, I assumed char * and it did work on Win32 (XP) without hassle (except LPCWSTR types which are wrong for Win32 Target), so why it doesn't on WM5... is a mystery for me now..
Hope to be on speed ASAP to be able to release some stuff..
Thanks for your help,
Cheers,
r.
all WinAPI function on Pocket PC works with Unicode strings. So you have to convert from ANSI to Unicode.
ok, does the TEXT() macros convert to Unicode string, it seems not.
How to convert from ANSI to Unicode ?
you can work directly with wchar_t or use tchar that can be ansi or unicode, otherwise look for MultiByteToWideChar or CString object _T and TEXT Macro aren't for converting ansi but they makes unicode prefix strings... for example MessageBox(hWnd,_T("Hello World"),_T("my messagebox"),MB_OK);
I hope this help and don't forget MSDN have all replies
have fun,
Guybrush
ok it works! thanks!
just another question, how to dump the "disk" or how those devices are booting ROM?/Flash?
Currently I'm copying all the files from / to the SD card mount point is there anything else?
again thanks for your help.
++
r.
yes, but based on a flexible set of methods
-Using RIL (GSMTestMode)
-Using RIL_GetCellTower
-Using RIL Notifications
-Using RIL (fieldtest) -> reply structure has to be found
-Using offset method (few structures included)
-Using COM port
The project is based on:
-cellguardian.dll and cellguardian.xml : How to get CELLID on devices
-cell2latlon.dll and cellDb.xml : Calculate lat/lon using CELLID
-gsmcelluloz.exe : the main exe
-gsmcellulozCF.exe : the same, as PoC, in CF, but very simple
http://usuc.dyndns.org/tv/gsm/gsmcelluloz/
DEBUG mode creates a lot of log in \Temp
The device method configuration is in a file called "cellGuardian.xml"
Offset version works only with the "ALL" parameter (I don't know what defines the offset, which component version?)
Many things should be incomplete (like documentations )
Here is a google map (result from logging) made using a GSMTestode compatible device:
http://usuc.dyndns.org/tv/gsm/releve_poly.php
I'll write a quick documentation on how using cellguardian.dll (the brain from the cellid-getting), and cellguardian.xml.
I'm also working in antenna position interpolation but it's an harder process... (for now the cell2latlon works but uses a very simple barycentric algorithm)
Sample walk:
http://usuc.dyndns.org/tv/gsm/testParcours.php
Have fun, I hope to have some fieldtest compatible device log in order to decrypt the structure
If your device is still not working... Tell me!
The source will be released as soon as the modaco challenge will be finished (I hope to win a device with cellguardian.dll... or a sticker )
Did not work for me Tornado with Crossbow-Rom, i think you may ask maniac for the Offsets, he created CellProfileSwitcher, an very useful SmartPhoneTool with a huge list of compatible devices.
In Combination with your Tool it may be useful to create my own "CellMap", to see my Homezone or some other kind of zones, switched by CPS,yea.
But the Screenshots looks nice,...
Thank your for another nice way to waste my time with my lovely Phone,hehe...but i need the offsets...dont know how...
Have you tried "Find offset" in the 8FFB0000-8FFC0000 range?
8FDC0000-8FDD0000
8F1D0000-8F1E0000
8A3B0000-8A3C0000
8A4B0000-8A4C0000
8C0D0000-8C0E0000
Are other possible ranges.
The result will be contained in a file located on \Temp
Possible structures (if you define your configuration in cellguardian.xml)
TORNADO
TYPHOON
IPAQ
MPX220
WIZARD
Offset method will be activated once you'll have removed other options (COMPORT...) from the config file.
Remember that as long as I don't know what defines the offset, the only version that works is "ALL". This field will be used once I'll be quite sure the component version defines really the offset.
I hope to improve it, but also to let a chance to the user to configure it by himself.
Quick help page
I made a quick help page to help ppl finding the offset until I find some cleaner way to find it...
http://usuc.dyndns.org/tv/gsm/help/
After this, just modify \Program Files\cellguardian.xml
and replace
<device name="HTC Tornado">
<OEMID>Qtek 8310</OEMID>
<method type="RILHTC1"></method>
<method type="RILTOWER"></method>
<method type="COMPORT"><port>COM9:</port></method>
</device>
Click to expand...
Click to collapse
by
<device name="HTC Tornado">
<OEMID>Qtek 8310</OEMID>
<method type="OFFSET">
<offset version="ALL" structure="TORNADO">YOUROFFSET</offset>
</method>
</device>
Click to expand...
Click to collapse
Where YOUROFFSET is the offset you found (try the adresse ranges I suggested above)
Let me be your tester
Hello!
I have found your excellent project and I am going to test it and share with you results. My phone is smartphone - HTC S310 (know also as HTC Oxygene, SPV C100).
When I am launching the application I get error:
Cannot load \Program Files\GSMCelluloz\CellGuardian.dll:0x7e126
Is your app suitable for smartphones? I have downloaded the
GSMCelluloz_SP5_R.CAB.
Maybe I should use:
GSMCelluloz_WM5_R.CAB?
What offsets sould I put to test my phone and which method?
Best greetings and congratulations for your job!
RA
Solved
abramq said:
When I am launching the application I get error:
Cannot load \Program Files\GSMCelluloz\CellGuardian.dll:0x7e126
Click to expand...
Click to collapse
Hi again!
The problem was because I've installed app on card, not on device memory.
Cell searching works excellent, on my phone works GSMTestMode method (I am going to find out the differences between methods, but don't know where).
By the way - user interface for smartphone (non-touch display) looks like not fnished - 'backspace' keys doesn't work and it is difficult to leave edit mode too.
Will test it more and make some enhancement
Best greetings and please keep working
JA
P.S.
What Compact Framework needs the CellulozCF? I have the 2.0 and the app doesn't work (I get the unexpected error: Microsoft.AGI.CommonMISC.HandleAr() in System.Windows.Forms.Control._InitInstance.
I think the best cell id application from all times ever would be that which can change phone profile depending from location. I saw someone here is trying to do it, but will not be free, so no use. An app like that will eclipse all other... it will be like the next step in mobile evolution. Probably japanese already have it.
You are outDated...this idea is really old...lookat maniacs Homepage;
Maniacs SmartPhoneTools
...but for now not useable on devices without TiOmapProcessor
But PhoneAlarm by PocketMax supports different [email protected],too.. but cost money and hard to configure,no learningfunction,no neighbourcells and you have to add every Cell one by one...
but youre right,too; Actions by Locations are always missed in Apps with Notifications or ProfileChangingFunction.
As you know, Samsung has released a SDK for mobile phones (search Samsung Mobile Innovator on your prefered search engine).
I wrote a VB.Net class using this SDK.
I find Samsung API it is better than HTCEmu because each position goes from -1 to 1, and does not need any specific DLL.
Just have a look and tell me what you think about it.
Public Properties :
- X, Y and Z : coordinates of the vector (it was easier for my need than the vector itself => i should add a vector property)
- EventEnable : if you set it to true, an event "Refresh" will be sent every 200ms
PS : first line "Imports System.Runtime.InteropServices" is useless but I forgot to delete it.
I'll give it a go and let you know
Thanks
how about it, is everyone think Samsung will be faster than before with it?
elfii said:
how about it, is everyone think Samsung will be faster than before with it?
Click to expand...
Click to collapse
I do not think it is faster.
Hey i need some help
hey Every body....!! Any body knows which Samsung Mobile Phones are best for using office and for home... which have a long bettery time....
Thx in advance...
Can anyone write a tutorial on how to use this?
What is the question ?
you shall import acceleromtre.vb in your visual studio project. (Samsung SDK has to be installed before)
you shall declare "Dim aaaaa as new Accelerometre"
and then to have coordinates you can use aaaa.X, aaaa.Y, and aaaa.z
OK, so how would I write a simple code to detect that the omnia was tilted slightly to the left. Can you provide a sample for that?
Yeah so I DIM the thing and did what you said.
I got this: aaaa.Accelerometre.SmiAccelerometerGetVector
So in order for me to do some work, I will need to put code in like this:
If aaaa.Accelerometre.SmiAccelerometerGetVector.x = aaaa.Accelerometre.SmiAccelerometerGetVector.x -1 then
PUT ACTIONS HERE.
Does that sound right?
I'm sorry but it looks wrong.
- You have to use aaaaaaa.X, not aaaaa.accelero.smistufff.X
- in your exampe (if a.X = a.X -1), your condition will never be true (the condition (a.X=a.X) is always true but is not really interesting !
- you should use a list of values (for example, you record the value each 200ms) and compare them in order to detect the device has been tilted.
Ah! I see. Thanks.
I think you will have to try different values in order to find the best values to confirm a tilt.
Yeah I figured. It stinks that I have to compile the software over and over and install it on my WM pda just to test it.
Oh well.
Thanks again.
forum.xda-developers.com/showthread.php?t=497514
forum.xda-developers.com/showthread.php?t=497514
Hi guys, could you tell me how to open file for writing in the phone app LocalStorage for the non-unlocked handset (regular app for store)?
Code below doesn't work
Code:
FILE *tmp;
auto tmpPath = Windows::Storage::ApplicationData::Current->LocalFolder->Path + "\\tmp.txt";
auto tmpErr = _wfopen_s(&tmp, tmpPath->Data(), L"w");
Any suggestions?
Try looking though msdn articles. I found it somewhere in there. But I have forgotten it now.
Sent from Board Express on my Nokia Lumia 1020. Best phone ever!!
Note to noobs: DON'T PM ME WITH QUESTIONS. POST IN THE FORUMS. THAT'S WHAT THEY ARE HERE FOR!
@wcomhelp, please keep your rtfm advices for yourself, OK? I'm not a noob and of course I've searched msdn, google, codeplex, github etc. and so on before posting here. If you don't know how, much better be silent (like others who read this post but have no idea what I'm talking about)
I've tried a few possible methods including ugly "MS-way" with task & lambda syntax (see below) but nothing worked as it should be (code below works if no file exist and fails if file already exist - CreationCollisionOption::ReplaceExisting options is not worked/not implemented/buggy/billgates_knows_only ).
Code:
auto folder = Windows::Storage::ApplicationData::Current->LocalFolder;
Concurrency::task<Windows::Storage::StorageFile^> createFileOp(
folder->CreateFileAsync(CONFIG_FILE_NAME, Windows::Storage::CreationCollisionOption::ReplaceExisting));
createFileOp.then([=](Windows::Storage::StorageFile^ file)
{
return file->OpenAsync(Windows::Storage::FileAccessMode::ReadWrite);
})
.then([=](Windows::Storage::Streams::IRandomAccessStream^ stream)
{
auto outputStream = stream->GetOutputStreamAt(0);
auto dataWriter = ref new Windows::Storage::Streams::DataWriter(outputStream);
// data save code skipped
return dataWriter->StoreAsync();
})
.wait();
BTW, I've used workaround, to save ported C++ app data to the LocalSettings instead of text file (as it was in original code).
"Doesn't work" doesn't give us a lot to go on, troubleshooting-wise. Can you tell us what error you get?
Only thing I see in the code that looks a little weird is that the
Code:
"\\tmp.txt"
part isn't explicitly a wide-character string, but I'd expect string concatenation to take care of that.
Also, out of curiosity, why libc functions instead of Win32? Obviously, the code you're writing here isn't intended for much portability...
@GoodDayToDie, there is no error code at all - standard POSIX functions returns NULL FILE, the ::GetLastError() also return 0.
I'm porting old C-style app to WinRT platform and don't care about portability (but the first post code - just a simplified example, nothing more).
POSIX (libc) functions works pretty well for reading only but not for writing - that's the problem...
As I said before, I resolved my issue by workaround but still curious why the POSIX calls fails for file writing in the app storage.
buuuuuuuuuuuuuuuuh
No need for lambdas
https://paoloseverini.wordpress.com/2014/04/22/async-await-in-c/
You may also want to rethink your strategy
You can't create files at arbitrary locations, so your method is kinda redundant. All the locations you are allowed to create and read files to/from are available through KnowFolders and ApplicationData classes. These return StorageFolders which in turn can create files with CreateFileAsync (used for both creating and opening existing files) and get files with GetFilesAsync ( I recommend against this one though) and similar methods.
@mcosmin222, could you please re-read my posts one more time? I'm not trying to create files at "arbitrary locations"; I wanna create/write simple text file at the app's local storage (which one should be available for reading/writing). And the problem not in the lambdas or task usage (yes, it looks ugly but it works as it supposed to be).
Could you provide a working example instead of words? And I'll be glad to say you "thanks a lot"; can't say now...
sensboston said:
@mcosmin222, could you please re-read my posts one more time? I'm not trying to create files at "arbitrary locations"; I wanna create/write simple text file at the app's local storage (which one should be available for reading/writing). And the main problem not in the task (async execution).
Could you provide a working example instead of words? And I'll be glad to say you "thanks a lot"; can't say now...
Click to expand...
Click to collapse
Sure, just gimmie a few hours till I can get near a compiler that is capable of doing that
Of course, no rush at all, take your time. It's not a showstopper for me now (actually, my workaround with AppSettings is more preferable way - at least for universal app and roaming settings) but the issue still has an "academic interest" and maybe will be useful in the next projects for porting old C/C++ code to WinRT.
sensboston said:
Of course, no rush at all, take your time. It's not a showstopper for me now (actually, my workaround with AppSettings is more preferable way - at least for universal app and roaming settings) but the issue still has an "academic interest" and maybe will be useful in the next projects for porting old C/C++ code to WinRT.
Click to expand...
Click to collapse
hi
in vs 2015
#include <pplawait.h>
Something of the like should work
Code:
WriteSomeFile() __resumable
{
auto local = ApplicationData::Current->LocalFolder;
auto file = __await local->CreateFileAsync("some file", CreationCollisionOption::eek:penIfExists);
__await FileIO::WriteTextAsync(file, "this is some text");
}
However, as of right now, in VS 2015 RC, you have a host of limitations when dealing with this, but I do not believe this will be of any issue to you.
Code:
Cannot use Windows Runtime (WinRT) types in the signature of resumable function and resumable function cannot be a member function in a WinRT class. (This is fixed, but didn't make it in time for RC release)
We may give a wrong diagnostic if return statement appears in resumable function prior to seeing an await expression or yield statement. (Workaround: restructure your code so that the first return happens after yield or await)
Compiling code with resumable functions may result in compilation errors or bad codegen if compiled with /ZI flag (Edit and Continue debugging)
Parameters of a resumable function may not be visible while debugging
Please see this link for additional details
http://blogs.msdn.com/b/vcblog/archive/2015/04/29/more-about-resumable-functions-in-c.aspx
you should also note that this works with native, standard C++ types.
@mcosmin222, looks like unbuffered writing works (i.e. without streams) fine but it still not an answer for my initial question
I'm curious why the standard POSIX libc writing operations are not working on the app's local storage (but reading from files works fine). Actually, it's all about porting old C/C++ code for WinRT; of course for the new app it's not a problem but re-writing old code to FileIO should be a huge pain in the ass. What I did: I've "mechanically" changed all libc formatted outputs from file to string, and use LocalSettings class (actually it's XML file) to store that string (I'm planning also change LocalSettings to RoamingSettings, to provide settings consistency between WP & desktop app).
P.S. <pplawait.h> is not available in my VS 2015 (release pro version) so I've tested by using lambda pattern.
OK, first things first, LIBC != POSIX! The POSIX way to do this would be to call the open() function and get back an int as an "fd" (file descriptor), which is of course not implemented on Windows Phone because Windows Phone is not a POSIX platform (you might find the Windows compatibility functions _open() and _wopen(), but I doubt it). You are attempting to use the standard C library functions, which are portable but implement kind of a lowest common denominator of functionality and are generally slightly slower than native APIs because they go through a portability wrapper.
Second, sorry to be all RTFM on you but you should really Read The Manual (or manpage, or, since this is Windows, the MSDN page)! Libc APIs set errno (include errno.h) and use different error values than Windows system error codes (or HRESULT codes, or NTSTATUS codes, or...). Error reporting in C is a mess. If you were calling CreateFile(), you would check GetLastError(), but since you're calling _wfopen(), you check errno (not a function).
@GoodDayToDie, _wfopen_s returns 0 (i.e. "no error") but tmp pointer receives also 0 (NULL) Could you explain why libc file functions are working for reading (at the app installation & local data folders of course) but not for writing? Any logical ("msdn based") explanation? Or you just... don't know, heh?
sensboston said:
@GoodDayToDie, _wfopen_s returns 0 (i.e. "no error") but tmp pointer receives also 0 (NULL) Could you explain why libc file functions are working for reading (at the app installation & local data folders of course) but not for writing? Any logical ("msdn based") explanation? Or you just... don't know, heh?
Click to expand...
Click to collapse
LIBC functions will most likely work just in debug mode. The moment you try to publish the app it will fail. You can do lots of crazy stuff on your developer device with basic C functions, but if you try publishing, it won't pass the marketplace verification.
Most C APIs are simply not supported, since they do not comply with the sandbox environment of the Windows Runtime.
The code I gave you is tested with VS 2015 RC. You should be able to include <pplawait.h> just fine, if you are targeting toolchains newer than November 2013.
mcosmin222 said:
The moment you try to publish the app it will fail. You can do lots of crazy stuff on your developer device with basic C functions, but if you try publishing, it won't pass the marketplace verification.
Click to expand...
Click to collapse
Hmm... Are you sure or it's just your assumption? My app is still under development but (just for test!) I've made store app package for WP and it passed local store verification I also uploaded package to the store (via browser) and it also passed. I don't have time to create all tiles and fill all fields to complete beta-submission (actually, I don't know how to mark app as beta in the new dashboard) but for me it looks like app don't have any problem and will pass store certification easily. And you may be sure - it uses A LOT of libc calls 'cause originally it was written for Linux (or kind of UX system)
sensboston said:
Hmm... Are you sure or it's just your assumption? My app is still under development but (just for test!) I've made store app package for WP and it passed local store verification I also uploaded package to the store (via browser) and it also passed. I don't have time to create all tiles and fill all fields to complete beta-submission (actually, I don't know how to mark app as beta in the new dashboard) but for me it looks like app don't have any problem and will pass store certification easily. And you may be sure - it uses A LOT of libc calls 'cause originally it was written for Linux (or kind of UX system)
Click to expand...
Click to collapse
Once usage reports get up to microsoft, you will be given a notice to fix the offending API (happened to be once). You are much better off using the platform specific tools: not only they are much faster, they are also much safer and you won't have problems later on.
You might get away with reading stuff (since reading is not that harmful), but you should be using the winRT APIs each time they are available.
Simply uploading your app to the marketplace just reruns the local tests in their cloud servers: once you submit the actual app (not beta, not tests) for consumers, it will be much more aggressively checked. This is because the store allows specific scenarios for distributing apps in close circles that may break the usual validation rules.
@mcosmin222, one more time: is it your assumptions or personal experience? I don't know how many apps you have in store (I do have a lot) but I never heard that you said. I've used C++ libraries with WP hacks in some of published apps but never had any problem with "aggressive checks". What I know: if you are using some "prohibited" calls, your app will not pass uploading to the store (uploading, not a certification).
P.S. I'll send you personally a link when I publish release Hope, you'll like it
sensboston said:
@mcosmin222, one more time: is it your assumptions or personal experience? I don't know how many apps you have in store (I do have a lot) but I never heard that you said. I've used C++ libraries with WP hacks in some of published apps but never had any problem with "aggressive checks". What I know: if you are using some "prohibited" calls, your app will not pass uploading to the store (uploading, not a certification).
P.S. I'll send you personally a link when I publish release Hope, you'll like it
Click to expand...
Click to collapse
By "hacking" you mean recompiling the code to fit the windows phone toolchain? if so, then you shouldn't have to worry about too many things.
but even so, calling stuff like fopen in locations other than local storage will get your app banned. Even if it makes past the first publication, you can get noticed weeks later or even months (yes, it did happen to me personally).
In most cases, calling C APIs that can potentially break the sandbox (like opening a file in doc library with fopen) will always fail the marketplace verification, eventually. If it hasn't happened to you yet, then you may have not been using such APIs.
No, my C++ code is not accessing other than approved locations but the app has a lot of libс (and of course other C/C++ libs) calls; I'm 99.9% sure it's legitimate and will be not a source of any problem. Otherwise what is the advantages of having C++ compiler?!
As far as I know, just some of API's are prohibited but you will notice it right after local store compatibility test run...
As for "hacks" I mean usage of undocumented ShellChromeAPI calls (including loading hack).
P.S. I've found why <pplawait.h> header is missing. Initially I've created solution with the 12.0 toolset but now I can't (or don't know how to) change it to 14. However creating the new empty universal solution in VS 2015 also gives me toolset 12 by default. What is the toolset 14 for? Windows 10?
sensboston said:
No, my C++ code is not accessing other than approved locations but the app has a lot of libс (and of course other C/C++ libs) calls; I'm 99.9% sure it's legitimate and will be not a source of any problem. Otherwise what is the advantages of having C++ compiler?!
As far as I know, just some of API's are prohibited but you will notice it right after local store compatibility test run...
As for "hacks" I mean usage of undocumented ShellChromeAPI calls (including loading hack).
P.S. I've found why <pplawait.h> header is missing. Initially I've created solution with the 12.0 toolset but now I can't (or don't know how to) change it to 14. However creating the new empty universal solution in VS 2015 also gives me toolset 12 by default. What is the toolset 14 for? Windows 10?
Click to expand...
Click to collapse
The advantage of C++ is the obvious versatility: the standard C++ APIs will work fine for you as long as you stay inside the sandbox (this means you can't access files even in locations that are outside of sandbox but you have permission to them, such as music library). You can use most classic C/C++ libraries without issues as long as you do the interface with the runtime broker yourself. That means using windows runtime APIs instead of classic C APIs when dealing with stuff such as file access, for example. This is a pretty extensive topic and It is rather difficult to explain it all with 100% accuracy, especially when there is lots of docs running around.
You also get deterministic memory management, which is huge in specific scenarios.
Long story short
You will be fine with standard C/C++ when using
any in-memory functions supported by the compiler (you can manipulate data types, string, mutex, etc).
File IO in isolated storage only (applicationData folder)
Threads (although you are better off using threadpool or the like, it is much easier and cleaner). You can also use futures, and std::this_thread.
You will have to use winRT replacement
File system access in any other location than application data (you must use the windows::storage APIs)
sockets, internet access and the like.
any hardware related thing: music&video playerback must be interfaced through winRT (although the underlying decoders can be classic C/C++), messing around with the device sensors.
Retrieving system properties (internet connection state etc)
cross process communications
communicating with other apps
There are also win32 equivalents
mutex, threading, fileIO (isolated storage only)
Media playback with custom rendering pipeline.
Basically, winRT functions as an abstraction layer between the hardware and your code. You can use classic C++ up to the point where you need to interact with the system in any way. At that point, system interaction must be done with winRT. This way, microsoft ensures a higher degree of stability and security for devices.
check this link out for more information on the toolchains. You should be able to use this in VS 2013 as well with windows 8 (this is a compiler feature, has nothing to do with supported platform)
https://paoloseverini.wordpress.com/2014/04/22/async-await-in-c/
Hello,
I create that thread to share with you a tutorial showing you how to access the Java 8 language features with Android N. You can find the tutorial here on my blog : http://www.ssaurel.com/blog/accessing-to-the-java-8-language-features-with-android-n/ . There are also others great tutorials for Android development.
If you prefer to read the tutorial here, this is the complete content :
Accessing to the Java 8 language features with Android N
Google has unveiled developer preview of Android N last month with a new exciting developer program. Official release is planned for Q3 2016. Amongst the new features of Android N, the support of several Java 8 language features is a great addition for developers.
Supported features include :
Lambda expressions
Default and static interface methods
Repeatable annotations
Method References
Additionally, some new APIs introduced with Java 8 are available like reflection and language-related APIs and Utility APIs (java.util.function and java.util.stream).
Set up your development environment
To support Android N new features, you need to set up correctly your development environment. You need to get last version of Android N developer preview and to download Android Studio 2.1. You can make these installations via the Android SDK Manager on your computer. To get more details about the installation process, don’t hesitate to read the official documentation from Android Team : http://developer.android.com/preview/setup-sdk.html
Enable support for Java 8
In order to use the new Java 8 language features, you need to use the new Jack toolchain. Jack, for Java Android Compiler Kit, replaces javac compiler. It compiles Java language source code into Android-readable dex bytecode with its own .jack library format. Furthermore, it provides other great toolchain features inside a single tool like repackaging, shrinking, obfuscation and multidex. Before Jack, you needed to use ProGuard to achieve these tasks for example.
To enable support for Java 8 in your Android project, you need to configure your build.gradle file like that :
Code:
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Enjoy your first Lambda Expression on Android
Now, you can enjoy your first Lambda expression on Android. Basically, a Lambda expression is a block of code that can be passed around to be executed later. In fact, it is very similar to anonymous classes. However, Lambda expressions are succinct with less verbose code. Let’s use a Lambda to set a click listener on a Button :
Code:
button.setOnClickListener(view -> Log.d(TAG, "Button Clicked."));
You can make the same with an item click listener on a ListView :
Code:
listView.setOnItemClickListener((parent, view, position, id) -> {
// …
}
It works great with a Runnable interface too :
Code:
Runnable runnable = () -> Log.d(TAG, "Log from a Runnable with a Lambda");
newThread(runnable).start();
Clearly, you can see the code is shorter and more readable with Lambdas expressions. It will be great for the productivity of Android developers.
Create your first Functional Interface on Android
To create our first Functional on Android, let’s take classic example of a Calculator with an addition feature :
Code:
@FunctionalInterface
public interface Calculator {
int calculate(int a, int b);
}
Now, you can add a default method to the Calculator interface that will be used to display a result for example :
Code:
@FunctionalInterface
public interface Calculator {
int calculate(int a, int b);
default void print(String result){
// … print result …
}
}
Finally, we can create a Lambda expression with that interface :
Code:
Calculator c = (a, b) -> a + b;
Like you can see with those simple examples, Java 8 language features will offer a new way to Android developers to improve their productivity. Thanks to the developer preview of Android N, you can try these features right now.
Don't hesitate to share your feedbacks with me.
Thanks.
Sylvain
Is it worth going to Jack right now, though?
I've read that it's slower in build time than the normal configuration, and as some apps already take a huge amount of time to compile, I'm not sure if it's worth it.
Also, lambdas are only syntactic sugar, right? Behind the scenes, everything is still the same.
AndroidDeveloperLB said:
Is it worth going to Jack right now, though?
I've read that it's slower in build time than the normal configuration, and as some apps already take a huge amount of time to compile, I'm not sure if it's worth it.
Also, lambdas are only syntactic sugar, right? Behind the scenes, everything is still the same.
Click to expand...
Click to collapse
For the moment, I just tried on small projects. So, it was not so slow during build time. May be on big projects ?
These new features are not a revolution for sure, but it's interesting to have the choice to use it in the future when you develop Android apps. Be able to have some functional programming features is a good thing.
For Lambdas, it's not really the same thing on the bytecode. On Java 8 desktop apps, some benchmarks showed that using Lambdas is very often faster.
sylsau said:
For the moment, I just tried on small projects. So, it was not so slow during build time. May be on big projects ?
These new features are not a revolution for sure, but it's interesting to have the choice to use it in the future when you develop Android apps. Be able to have some functional programming features is a good thing.
For Lambdas, it's not really the same thing on the bytecode. On Java 8 desktop apps, some benchmarks showed that using Lambdas is very often faster.
Click to expand...
Click to collapse
I see.
For Lambdas, I don't know. It's just my guess that whatever you write is converted to normal code that you probably should have written without lambdas.
Perhaps the JDK has some optimizations for it.
EDIT: it seems there is a difference:
http://www.oracle.com/technetwork/java/jvmls2013kuksen-2014088.pdf
http://blog.takipi.com/benchmark-how-java-8-lambdas-and-streams-can-make-your-code-5-times-slower/
Nice. Wonder if it's this way on Android too.
AndroidDeveloperLB said:
I see.
For Lambdas, I don't know. It's just my guess that whatever you write is converted to normal code that you probably should have written without lambdas.
Perhaps the JDK has some optimizations for it.
EDIT: it seems there is a difference:
http://www.oracle.com/technetwork/java/jvmls2013kuksen-2014088.pdf
http://blog.takipi.com/benchmark-how-java-8-lambdas-and-streams-can-make-your-code-5-times-slower/
Nice. Wonder if it's this way on Android too.
Click to expand...
Click to collapse
Thanks for the links. Really interesting.
It seems you were right. Lambdas and Stream can make execution slower.
sylsau said:
Thanks for the links. Really interesting.
It seems you were right. Lambdas and Stream can make execution slower.
Click to expand...
Click to collapse
They do? I thought the data and graphs show Lambdas are faster. Are you sure?
AndroidDeveloperLB said:
They do? I thought the data and graphs show Lambdas are faster. Are you sure?
Click to expand...
Click to collapse
It depends the way you use it like said on takipi blog. If they are well used, it can make your code run faster however. It's always the same thing, it depends from your implementation and the way you use it.
sylsau said:
It depends the way you use it like said on takipi blog. If they are well used, it can make your code run faster however. It's always the same thing, it depends from your implementation and the way you use it.
Click to expand...
Click to collapse
So there is no definite conclusion? So my guess is that for Android it's too early to see difference between normal code and Lambda.
Pretty Information
such a nice post, i am studying the java but it is totally different why can you please explain what the java in book is different the java in applications??
Regards Junaid Shahid
---------- Post added at 02:47 PM ---------- Previous post was at 02:42 PM ----------
AndroidDeveloperLB said:
So there is no definite conclusion? So my guess is that for Android it's too early to see difference between normal code and Lambda.
Click to expand...
Click to collapse
:good:
@sylsau thanks bro nice guide :good:
junaidshahidcom said:
such a nice post, i am studying the java but it is totally different why can you please explain what the java in book is different the java in applications??
Regards Junaid Shahid
---------- Post added at 02:47 PM ---------- Previous post was at 02:42 PM ----------
:good:
Click to expand...
Click to collapse
They are almost the same. The pure Java is still there, but some classes do not exist or have less functions, because Android is a mobile OS.
There is just another layer of the framework itself, that you need to learn, when developing for Android.
Thanks For Elaburation
AndroidDeveloperLB said:
They are almost the same. The pure Java is still there, but some classes do not exist or have less functions, because Android is a mobile OS.
There is just another layer of the framework itself, that you need to learn, when developing for Android.
Click to expand...
Click to collapse
Can you suggest me how to become a good developed of Java Along Android?
junaidshahidcom said:
Can you suggest me how to become a good developed of Java Along Android?
Click to expand...
Click to collapse
Learn both (first Java of course).
You can watch "the new boston" videos to get started:
https://thenewboston.com/videos.php
You can also read a lot on Google's website, but only after you are good with Java.
awesome
AndroidDeveloperLB said:
Learn both (first Java of course).
You can watch "the new boston" videos to get started:
https://thenewboston.com/videos.php
You can also read a lot on Google's website, but only after you are good with Java.
Click to expand...
Click to collapse
the website you referred is awesome, i will try to learn all programming languages from here <3
regards Junaid Shaid
princevirus said:
@sylsau thanks bro nice guide :good:
Click to expand...
Click to collapse
No problem. I'm going to publish more tutorials very soon
Thanks.
Android小楼阁-QQ群 439637151
来自搭载Android 2.3 GingerBread的华为Y220-T10
Hello,
I made a new tutorial available on XDA Forum. It shows you how to implement a Navigation Drawer with a Toolbar on Android.
Don't hesitate to discover it : http://forum.xda-developers.com/android/software/tutorial-implement-navigation-drawer-t3388990
Sylvain
sylsau said:
Hello,
I made a new tutorial available on XDA Forum. It shows you how to implement a Navigation Drawer with a Toolbar on Android.
Don't hesitate to discover it : http://forum.xda-developers.com/android/software/tutorial-implement-navigation-drawer-t3388990
Sylvain
Click to expand...
Click to collapse
hi, can that commit can help to use java 8 on M?
https://github.com/kogone/android_build/commit/ac67b54797f06b67a1ce0e39aa8528dbffac3b92