Launch Program - Windows Mobile Development and Hacking General

Hi,
I'm trying to code a simple app and need to be able to launch a program from within the app. I'm initially coding in VB, and then will probably move it over to C#
It seems the shell() command does not work on the CE platform. I've trawled through thousands of forums, but can't find anything to help.
The best I've been able to find will launch a program, but only 'windows' programs - I can't get it to launch anything that has been personally installed on the device.
I figure a few of you here would know how to do it...
Would love a bit of help... It's driving me crazy....

k1sr said:
Hi,
I'm trying to code a simple app and need to be able to launch a program from within the app. I'm initially coding in VB, and then will probably move it over to C#
It seems the shell() command does not work on the CE platform. I've trawled through thousands of forums, but can't find anything to help.
The best I've been able to find will launch a program, but only 'windows' programs - I can't get it to launch anything that has been personally installed on the device.
I figure a few of you here would know how to do it...
Would love a bit of help... It's driving me crazy....
Click to expand...
Click to collapse
Look for ShellExecuteEx or CreateProcess on msdn.

Here is the code in C#
Code:
using System.IO;
using System.Reflection;
...
FileSystemInfo f = ...
try
{
Process p = new Process();
p.StartInfo.FileName = @"" + f.FullName;
p.Start();
}
catch (System.Exception) { }

place the codes in
Code:
Click to expand...
Click to collapse
tag

ather90 said:
place the codes in tag
Click to expand...
Click to collapse
Sorry :S and thankx

no worries, while going through my old projects, i found this
Code:
System.Diagnostics.Process.Start("\\windows\calender.exe", ""); // Start the calender
i use it like this :
Code:
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("\\Windows\calender.exe", ""); // Start the calender.
}

Thanks All,
I'll give these a go tonight...
ather90 - will this work for non windows programs - as that seemed to by my issue - ie. can I start \internal storage\programs\myprogram.exe
Thanks...!

k1sr said:
Thanks All,
I'll give these a go tonight...
ather90 - will this work for non windows programs - as that seemed to by my issue - ie. can I start \internal storage\programs\myprogram.exe
Thanks...!
Click to expand...
Click to collapse
this will work for any application that runs on your device when you click on it's icon,
just use the full path and go.

Thank you all...!!!
I was about to top myself...
System.Diagnostics.Process.Start("\\windows\calender.exe", "") was my saviour...
I can't believe how hard this was to find anywhere...

Related

What code language is this?????

I found this code posted on another thread, but was wondering... What language is this? And what software do I need to compile it? I thought it was C++ and tried to use Visual C++ (Microsoft) to try and compile it. I saved the file as a .cpp and tried to compile it from the command prompt (cl /clr filename.cpp). Thanks in advance. I have little experience in this area, but I'm trying to learn.
Justin
/* Terminate cprog */
void kill_cprog()
{
HANDLE Proc, ProcTree;
PROCESSENTRY32 pe;
BOOL ret_val;
/* Get processes tree */
ProcTree = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe.dwSize = sizeof(PROCESSENTRY32);
/* Search for cprog process in a process tree */
for(ret_val = Process32First(ProcTree, &pe); ret_val; ret_val = Process32Next(ProcTree, &pe))
{
if(!wcsicmp(TEXT("cprog.exe"),pe.szExeFile))
{
/* Terminate cprog */
Proc = OpenProcess(0, 0, pe.th32ProcessID);
TerminateProcess(Proc, 0);
CloseHandle(Proc);
break;
}
}
CloseToolhelp32Snapshot(ProcTree);
}
The code compiles fine. Its plain win32, just make sure you include Tlhelp32.h or will get errors. I did not test if it dose anything. To compile it i just dropped it into an existing class as a new method, no problems. It looks like it wants to stop your phone process.
If you arer really new.... this code dose nothing by itself it needs to be part of a larger program. The code is used for stopping the process that is the phone on a ppc. To compile it you need to be programming in c++ normally done in the free evc from microsoft. In a file in your program eg someFile.h put the line #include <Tlhelp32.h> . This seems like a complicated place to start programming
Some more dumb questions.....
Where can I get the Tlhelp32.h? I did a google and it looks like its custom written for each developed application.
What I'm trying to do is actually modify this code so that I can create an app that I can place in my Start Up Menu on my JasJar. The app looks for a specific process (in my case a GPS application). Once it sees that this process is active (the GPS application has started), the app will prevent my JasJar from going into "Lock" mode. I think I've got it written correctly, but I'm confused on how to compile it.
I have programming experience, but I dont' know what a header file is. I don't know what a class is. I don't know what a method is. Is there a web site that explains all this?
Thanks Justin
I salute your attempt at programming the hard way :lol: . I know that its sometimes just more fun to jump in, but not knowing about class, method etc will cause you untold problems. Look on emule for some books on c++. Anyway... the file Tlhelp32.h came with evc 3.0 I think. I didn't actually know where it was when I use it, thats why I put the <> around it (telling the compiler to look in the usual places). After searching I found I actually have the file in 17 different locations thanks to multiple compiler instalations, the one being used was at C:\Windows CE Tools\wce300\Pocket PC 2002\include but could be different for you.
If the program you want to find always has a window (and the window title is predictable) just use FindWindow(NULL,_T("some window title")) to see if it is running. If it returns NULL then there is no program with that title running. If you want to see FindWindow in action get this...
http://odeean.veritel.com.au/ORDprocessManager/processKillerNoInterface.exe
and run it on your desktop pc. Press left shift and right shift for instructions. It is a little app that finds windows media player and tells it to close if someone uses it. No need for snapshots there.
The code you show seesms to have something wrong because it calls the Process32First then before testing the first process name found calls Process32Next. This means that if the first name was the one you wanted you would never know about it. Other than that your on the right track.
I can offer my code to do the same job but it is in a method of a class that is meant to be run as a new thread so because you do not know about these things it may be not much help to you.
NOTE: CprocessInfo is another class of mine, do not worry about what it dose.
//-----------------------------------------------------------------
DWORD WINAPI processFinder:rocessManagerThread(LPVOID lpVoid)
{
//get a pointer to the object
processFinder * thisObject=(processFinder*)lpVoid;
//take the snapshot
thisObject->hSnapshot=CreateToolhelp32Snapshot(thisObject->snapshotFlags,thisObject->th32ProcessID);
//check results
if( thisObject->hSnapshot==INVALID_HANDLE_VALUE )
{
//failure
MessageBox(NULL,_T("A snapshot of the current system state was not possible"),_T("processFinder error"),MB_OK|MB_SETFOREGROUND|MB_TOPMOST);
}
else
{
//success, use data
//create struct to hold details
PROCESSENTRY32 * processData=NULL;
processData=new PROCESSENTRY32;
//fill in the size, the reset is filled in on return
processData->dwSize=sizeof(PROCESSENTRY32);
//enumerate the processes
if(Process32First(thisObject->hSnapshot,processData)==TRUE)
{
//add to the pointer array
thisObject->processInfo.Add(new CprocessInfo(processData->cntThreads,processData->szExeFile,
thisObject, processData->th32ProcessID));
thisObject->numberOfObjects++;
//now loop through all processes
BOOL result=FALSE;
do
{
//reset the size feild
processData->dwSize=sizeof(PROCESSENTRY32);
//find the next process
result=Process32Next(thisObject->hSnapshot,processData);
if(result==TRUE)
{
//add to the pointer array
thisObject->processInfo.Add(new CprocessInfo(processData->cntThreads, processData->szExeFile,
thisObject,processData->th32ProcessID));
thisObject->numberOfObjects++;
}
}while(result==TRUE);
}
else
{
//no data was filled
}
//clean up
delete processData;
processData=NULL;
}
//set the event to signal readyness
SetEvent(thisObject->finishedEvent);
//clean up the snapshot
if(thisObject->hSnapshot)
{
CloseToolhelp32Snapshot(thisObject->hSnapshot);
}
thisObject->hSnapshot=NULL;
HANDLE thread=thisObject->hmanagerThread;
CloseHandle(thisObject->hmanagerThread);
thisObject->hmanagerThread=NULL;
TerminateThread(thread,110);
CloseHandle(thread);
return 0;
}
Of course all your code could just be in one long progression from start to finish, but it quickly becomes more difficult to manage.
I Salute You!!!
Wow! The help your giving is fantastic! Thanks. I think I realize how much I'm in over my head. I found a machine at work with Visual .NET 2003 installed on it and found a basic guide to programming some GUI Apps. Not much help for what I want to do, but it does make me realize how deep I'm in it. Oh well, if it was easy, everybody would be doing it!
I'll have to look at your code tomorrow and try to compile it. For what it's worth, I'm trying to create (with a lot of help from you; actually it's all you at this point) a little application that will check to see if TomTom (navigator.exe & windowed), iGuidance or OCN/Navigon is running. If it is, this application will prevent my JasJar (with MSFP AKU2.0) from going into 'Lock' Mode.
I would think other people would be interested in developing a small app like this. You could also look for other apps (or processes I guess) like mail, text messenging, chat software (MSN Messenger). Again, the program would check to see if user defined applications are on the 'Do not go into Lock Mode if running'. It could be very versitle and powerful. Anyway, that's where I'm trying to head.
This 'lock function' in the new ROM upgrade stinks!
Again, thanks for your help.
Justin

Interest in a task automater / macro recorder and playback utility?

I wrote a program for Windows 2000/XP called Do It Again ( http://www.spacetornado.com/DoItAgain/ ) that does simple task automation (also called macro recording and playback).
You click "Create a New Task" and it then records all of your keystrokes and mouse clicks in any program until you hit a certain hot key (Scroll Lock by default). You can then run the task back in a number of different ways and it will recreate your keystrokes and mouse clicks... either with the same pauses in between, or it can speed them up. And there are some other options available as well (repeating tasks, manually extending pauses between actions, etc).
I thought something like this might be useful for Windows Mobile devices. I wrote Do It Again in C# using .NET Framework 2.0, so I'm guessing it should be fairly easy to port to .NET Compact Framework 2.0.
But I only want to start porting this to Windows Mobile if there is any interest in it, and if people think they might get some use out of it. I know for me personally there are several things I do on my WinMo device that get repetitive and monotonous... starting and minimizing GPS Test to activate the GPS adapter, dismissing old Notifications, marking all email as Read, etc.
This sounds like a perfect application which can be used for pretty much anything.
Personally, i'm very interested in this, and would be glad to have it ported.
There are a lot of people who're looking to do things the easy way around here, for instance, settings up accounts, changing settings.. and so forth, without having to go 8 clicks...
nir36 said:
This sounds like a perfect application which can be used for pretty much anything.
Personally, i'm very interested in this, and would be glad to have it ported.
There are a lot of people who're looking to do things the easy way around here, for instance, settings up accounts, changing settings.. and so forth, without having to go 8 clicks...
Click to expand...
Click to collapse
I would find this very useful for using both Google Maps and Tom Tom Nav.. Say you want to go somewhere new.. Use google maps to find the address and then activate the script, prime the GPS, load Tom Tom, then copy paste the address info into Tom Tom. One cycle activated by a hot key would be nice.
norkoastal said:
I would find this very useful for using both Google Maps and Tom Tom Nav.. Say you want to go somewhere new.. Use google maps to find the address and then activate the script, prime the GPS, load Tom Tom, then copy paste the address info into Tom Tom. One cycle activated by a hot key would be nice.
Click to expand...
Click to collapse
Yeah that would be a perfect example of how you could use it. And that would be a lot safer to have a task automation app perform those steps for you instead of having to do it yourself while driving.
I'll start working on this in a week or so (as soon as I can get Scrobble finished up and to a point where people stop requesting more features! ) and see if can be ported over.
It should be easy; there are just a couple Win32 library calls it makes that I'm not sure are available in WinMo 6.1:
Code:
// imports mouse_event function from user32.dll
[SRI.DllImport("user32.dll", CharSet = SRI.CharSet.Auto, CallingConvention = SRI.CallingConvention.StdCall)]
public static extern void mouse_event(int dwFlags, int dx, int dy, uint cButtons, uint dwExtraInfo);
// imports keybd_event function from user32.dll
[SRI.DllImport("user32.dll", CharSet = SRI.CharSet.Auto, CallingConvention = SRI.CallingConvention.StdCall)]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
These two functions mouse_event() and keybd_event() poll for all mouse and keyboard events (clicks, movement, keypresses, etc.) globally... in any window, program, and so on.
Does anyone know off the top of their head if user32.dll is also available in Windows Mobile 6.1 Professional?
I am *VERY* interested in this application. How is the porting coming? I can't wait!!!
Man. That would be a revolution for us ppccusumizenerds! Holy ****! ..that would actually be Holy ****!
There is a version of AutoHotKey for Pocket PCs / WinCE, still in development, but a lot of it working, see here http://www.autohotkey.com/forum/topic27146.html&highlight=wince.
I'm very interested. In fact, I was looking for such an application but gave up finding.
Looking forward.
Thanks.
Hi,
if it's getting as good as Scrobble, then I vote for it . This would be a very handy feature, moreover very clever.
I would test it with pleasure.
Greets.
It will be a very useful app!
Looking forward to it, in the meanwhile I'll play with XP version!!

VB.net help needed for an app Im halfway through writing.

Ive got to a point where Ive got to the limit of my knowledge.
(admitedly, I no pro, I just dont know how to do this)
Ive got a loop which finds out how many images are in a folder
and it makes a new picturebox for each image, sets the image
property to show that image and gives it a name, height, width,
location and parent.
My problem is I want to add a mouseclick event for each of these
items as I create them. I just dont have a clue how to do this.
Anyone got any ideas?
Ive tried this kinda thing, but it didnt work (stupid compact framework):
Code:
picturebox.MouseClicked += new MouseEventHandler(function_name);
Good Help Forum
http://www.vbforums.com/
It must work... Not sure how it is in VB.NET, but in C# it is this:
... in some method ...
PictureBox pb = new PictureBox();
.. setting properties
pb.Click += new EventHandler(PictureBox_Click);
... end of the method
private void PictureBox_Click(object sender, EventArgs e)
{
... here goes your code, the picturebox clicked is in (sender as PictureBox), event args are in e
}
Thanks for you help
Ive not managed to get anything working properly so far
but I have within the past 10 mins figured out how to get around having to do this ^_^
See, this is a autoload image:
Me.PictureBox1.Image = New System.Drawing.Bitmap("figure2.bmp")
And Example:
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/2896d5cd-06d1-4a70-a561-a2c3497e325c
I think this wouldn't have been a problem with older VB technology if it had supported WM development. By that I mean it supported object arrays and provided a method with an 'Index'. From what I can see .NET doesn't offer such a luxury.
Your code looks right (syntax); but would I be right in thinking that your loop recreates 'picturebox' each time it loops and you are trying to associate an array of 'picturebox' to a single 'MouseEventHandler' function?
Code:
picturebox.MouseClicked += new MouseEventHandler(function_name);
My method of programming .NET is pretty much trial and error so I can't say for sure, just waffling
This is an example on how i did this with c# and the paint event. You dont want the paint event but it should be easy enough to change.
private void GenerateDynamicControls(string extt)
{
PicBox = new PictureBox();
PicBox.Image = Properties.Resources.phone;
PicBox.Name = "picturebox" + extt.ToString();
PicBox.Width = 75;
PicBox.Height = 75;
PicBox.BackgroundImageLayout = ImageLayout.Center;
flowLayoutPanel1.Controls.Add(PicBox);
PicBox.Paint += new PaintEventHandler(picpaint);
}
private void picpaint(object Sender,System.Windows.Forms.PaintEventArgs e)
{
//Do whatever you need done here
}
//To Create the control do this.
GenerateDynamicControls(namethecontrolsomething);
Hope this helps.
In VB.Net, you need to use AddHandler. Quick search on the tutorial and I found, http://www.thescarms.com/dotnet/EventHandler.aspx
Hope this help.
smart device applcation
Sorry guys but I will use this thread to ask for your help regarding VB.Net.
Does anyone know how to browse the device and select a picture into a picture box?
Example:
I have a form with a picturebox and a button and what I want is by pressing the button to explore my device, choose a picture and update my picturebox with the picture selected.
There are loads of youtube videos with Windows Forms Applications tutorial but I just can not find one for a smart device applcation.
Any help?
Thanks

[Q] run 2 of the same programs at the same time?

is it possable to run two of the same programs at the same time?
maybe to run a script or something....
eg, if i open an .exe on device, i want to be able to open the same .exe but in a differant window so its running twice. (and ill be able to alt-tab betwene the two windows)
thanks
Rn
Have a look at post #2 of this thread.
do you think it is possable to do this with mortscript? i do not have VS
stephj said:
Code:
//If it is already running, then focus on the window
hWnd = FindWindow(szWindowClass, NULL);
if (hWnd)
{
// set focus to foremost child window
// The "| 0x01" is used to bring any owned windows to the foreground and
// activate them.
SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001));
return 0;
}
Click to expand...
Click to collapse
thanks
Rn
It depends on how the application was written originally. If it is a Win32 C++ program then the second copy will activate the first then terminate itself, as shown in the above code, unless the programmer has deliberately removed it.
.NET applications also seem to behave the same way. Windows CE was not really designed to run multiple instances of the same executable like the desktop versions of Windows.
Copying the .EXE file to another name might work, but the methods mentioned above could thwart your efforts.
i understand what you meen, i doubt changing the name will work but it might be worth having a go so i will try it when i next need the app open in 2 windows (not very often)
thanks dude
Rn
It's possible to make instances for some apps - crude, but working way - hexeditor and internal name change(of process they are creating).
I used this to make multiple instances of wm5newmenu few years ago.
Though, it's hard to say which app can be treated like this and which one won't work...sometimes app may need additional "fixes" with files they are using + hexedit of registry entries they are using, or config names(if app behaviour needs to be different in both instances, i.e.).
In IphoneToday, using ResHacker to change the name, we managed to launch multiple instances of IphoneToday.exe in order to generate folders http://forum.xda-developers.com/showpost.php?p=11032873&postcount=2727.
thanks, ill try editing the exe with reshacker
Rn
I think the pupakota said there's a reason, you can consult,don't suit copy phone

playing audio files in an app

Hi there
I am desperate for advice and support on how to develop an android app that plays music audio files.
The app itself would have a home screen, about screen and a tracks screen.
The user when they navigate to tracks screen would have a list view of music audio files they can listen to on their android device.
The music audio file itself can either be stored in a SQL server database or ftp site , I don't know what would be best in terms of delivering optimal performance for end user?
The app would be like a service that would just play in the back ground allowing users to use their phone whilst listening to the music track(s).
My problems are:
- how can I actually develop this?
- there are no tutorials on the net, all music playing apps on YouTube, stack overflow and other websites do not show how to read music from SQL or ftp server.
I would be eternally grateful to anyone who could kindly advise me:
- best way to store each music audio file? Ftp or SQL
- in any case SQL would have to be used I believe to store the weblinks if I were to use FTP
- each music file of which there are around 150-180 is around 100mb in size and is of mp3 quality
Please , please , please can you help me develop this? Or guide me so I may be able to do it.
Please advise me on best way to set this up and get me started...
Thank you in advance
xirokx said:
Hi there
I am desperate for advice and support on how to develop an android app that plays music audio files.
The app itself would have a home screen, about screen and a tracks screen.
The user when they navigate to tracks screen would have a list view of music audio files they can listen to on their android device.
The music audio file itself can either be stored in a SQL server database or ftp site , I don't know what would be best in terms of delivering optimal performance for end user?
The app would be like a service that would just play in the back ground allowing users to use their phone whilst listening to the music track(s).
My problems are:
- how can I actually develop this?
- there are no tutorials on the net, all music playing apps on YouTube, stack overflow and other websites do not show how to read music from SQL or ftp server.
I would be eternally grateful to anyone who could kindly advise me:
- best way to store each music audio file? Ftp or SQL
- in any case SQL would have to be used I believe to store the weblinks if I were to use FTP
- each music file of which there are around 150-180 is around 100mb in size and is of mp3 quality
Please , please , please can you help me develop this? Or guide me so I may be able to do it.
Please advise me on best way to set this up and get me started...
Thank you in advance
Click to expand...
Click to collapse
sounds like you need to do lots more research and maybe a few tutorials for a better understanding. I would suspect 99% of developers would host file though http/s (not ftp) and yes all song info and metadata in SQL and delivered though php.
Binary Storage in SQL is not out of the question using BLOBS but not well suited in your case.
hope that helps, sounds simple enough
sounds like you need to do lots more research and maybe a few tutorials for a better understanding.
Click to expand...
Click to collapse
thanks for your reply
i have tried looking for tutorials for hours on end and its a very niche area, i could not find any.....do you know of any? have you tried looking for tutorials?
I would suspect 99% of developers would host file though http/s (not ftp) and yes all song info and metadata in SQL and delivered though php.
Click to expand...
Click to collapse
how do you host mp3 files using HTTPs ?
sounds simple enough
Click to expand...
Click to collapse
if its that simple, perhaps you would not mind guiding me to acheive it?
the page in the app which contains the mp3 files would have a listview or gridview with the names of the mp3s so when user clicks on them the mp3 plays in the background...
perhaps you can create an example if possible? i would be so grateful.
thank you
xirokx said:
i have tried looking for tutorials for hours on end and its a very niche area, i could not find any.....do you know of any? have you tried looking for tutorials?
Click to expand...
Click to collapse
You will never find a tutorial to do an exact app for what you want But you will find 1000's of how to store and use data from a database, 1000's for how to use mySQL and php in android, 1000's for listviews and gridviews powered by adapters and data and again 1000's or hundreds on how to stream audio from web servers using android
xirokx said:
how do you host mp3 files using HTTPs ?
Click to expand...
Click to collapse
upload them ? not sure what your question is here, you place the file on the server and use the URL ?
xirokx said:
if its that simple, perhaps you would not mind guiding me to achieve it?
the page in the app which contains the mp3 files would have a listview or gridview with the names of the mp3s so when user clicks on them the mp3 plays in the background...
perhaps you can create an example if possible? i would be so grateful.
thank you
Click to expand...
Click to collapse
It contains such a generic set of tasks you really dont need me to write it for you.... I'm always happy to answer direct specific questions, but you will seldom get an answer for "how do I do x app"... but like I said, what you want is very common, so there is tonnes of resource online
thanks for your reply
You will never find a tutorial to do an exact app for what you want But you will find 1000's of how to store and use data from a database, 1000's for how to use mySQL and php in android, 1000's for listviews and gridviews powered by adapters and data and again 1000's or hundreds on how to stream audio from web servers using android
Click to expand...
Click to collapse
If only the world was perfect and I could find an "exact" tutorial.....If I thought it was that easy I would never have started my thread.
really? 1000s or 100s.....yet you cannot point me to one?
It contains such a generic set of tasks you really dont need me to write it for you.... I'm always happy to answer direct specific questions, but you will seldom get an answer for "how do I do x app"... but like I said, what you want is very common, so there is tonnes of resource online
Click to expand...
Click to collapse
if it is that generic and simple, I do not understand why you cannot guide me more, at least to the 1000's or 100's of tutorials you claim that exist and especially as I have mentioned I cannot find them.
Try and see it from my point of view, I am new to this, trying, well actually REALLY REALLY want to learn, have spent hours researching for adhoc tutorials that will enable me to grasp the "generic" concept and have not found much / anything to help me.
Then you come along and make such a bold claim basically saying its "simple and easy, generic and quite straightforward" yet you cannot backup your claim by providing any of these "easy to find, 1000's or 100s tutorials" and are not willing to help any more then this.
Personally if I thought something was that easy, how much of my valuable time is it really going to take me, to provide someone who wants to learn with a few lines of code to get them started, especially after making such BOLD claims....
If I was not willing to, I would not even bother replying, it would have been far more beneficial if you responded with some example code rather then claiming how simple it was to do, I see no evidence that is it so easy only your claims...
Thanks for your time
Seriously though, this is me using google
http://developer.android.com/guide/topics/data/data-storage.html
http://developer.android.com/training/basics/data-storage/databases.html
http://www.vogella.com/tutorials/AndroidSQLite/article.html
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
http://www.mybringback.com/tutorial...-using-remote-databases-php-and-mysql-part-1/
http://forum.xda-developers.com/showthread.php?t=2325799
http://developer.android.com/guide/topics/media/mediaplayer.html
http://stackoverflow.com/questions/18174068/how-to-play-the-online-streaming-radio-in-android
http://stackoverflow.com/questions/1965784/streaming-audio-from-a-url-in-android-using-mediaplayer
if you use google you will find 1000's more results, they were just the top ones really, not sure why you cant find any...seriously pages and pages of relevant results, what were you actually searching for ? as in search terms ... maybe thats the prob ?
Also yes it is generic and yes almost every app uses those components and has had to complete those tasks. Trust me on this, remote database + online resources are in 90% of apps But it's the tasks that have 1000s of tutorials and reference, not the app.... like i say "android database tutorial", "android mysql online database","android media stream url"
hope that helps
thanks alot....I will check them out and get back to you
so grateful for your help
maybe you can solve this, perhaps its "challenging" enough for ya
this is my android java code that a) connects to my db b) uses the Name field from my db to populate a listview in my app c) when any single listview item is selected, it uses the name in the listview matches it to the dbName and plays the dbFile which contain a URL to where the mp3 is stored:
Code:
private void connect() {
List<String> r = new ArrayList<String>();
ArrayAdapter<String>adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,r);
final ListView list=(ListView)findViewById(R.id.listView1);
try {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("myServer/android/files.php");
HttpResponse response = client.execute(request);
HttpEntity entity=response.getEntity();
data=EntityUtils.toString(entity);
Log.e("STRING", data);
try {
JSONObject jsonResponse = new JSONObject(data);
JSONArray jsonMainNode = jsonResponse.optJSONArray("mp3s");
for (int i = 0; i < jsonMainNode.length(); i++) {
JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
ID = jsonChildNode.getInt("ID");
name = jsonChildNode.getString("Name");
FileName = Uri.parse(jsonChildNode.getString("FileName"));
Log.e("STRING", name);
//r.add(ID);
r.add(name);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
MediaPlayer mp = new MediaPlayer();
try{
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.setDataSource(getApplicationContext(), FileName);
mp.prepare();
mp.start();
}
catch(IOException e)
{
System.out.println(e);
}
}
});
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClientProtocolException e) {
Log.d("HTTPCLIENT", e.getLocalizedMessage());
} catch (IOException e) {
Log.d("HTTPCLIENT", e.getLocalizedMessage());
}
}
Problem is:
- It doesnt open mediaplayer or streaming player on the emulator
- If track 1 is playing and I click on track 3 it plays both tracks simulateously
- as there is no media/stream player view you cannot pause/stop/play the track that is being played
pls help me fix these issues, if you can
thanks
p.s. I did use your links to get me this far, now I am genuinely stuck and would really appreciate a hand
thanks appreciate it
xirokx said:
Problem is:
- It doesnt open mediaplayer or streaming player on the emulator
Click to expand...
Click to collapse
Dont work with the emulator at all, I only use real devices, but if you mean the media player app, then thats due to you not using it. You're using the media player class.
xirokx said:
- If track 1 is playing and I click on track 3 it plays both tracks simulateously
Click to expand...
Click to collapse
Thats cause you create another instance that every click (or new instance rather). I would assume that you just should have 1 and stop/reuse it.
xirokx said:
- as there is no media/stream player view you cannot pause/stop/play the track that is being played
Click to expand...
Click to collapse
Well you would create buttons to do that yourself.
I am now debugging my app on my device
I have changed the code a little so only 1 file plays at any one time and it works....
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
//playAudio(FileName);
Uri uri = FileName;
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
Click to expand...
Click to collapse
However when I click on the list item, a menu opens up asking which browser I want to play the file in....when instead it should open a list of mediaplayers for me to play the file in.
How can I change it?
Thanks for your help.
xirokx said:
I am now debugging my app on my device
I have changed the code a little so only 1 file plays at any one time and it works....
However when I click on the list item, a menu opens up asking which browser I want to play the file in....when instead it should open a list of mediaplayers for me to play the file in.
How can I change it?
Thanks for your help.
Click to expand...
Click to collapse
well thats the way it will work if down to the user not choosing a default and also the way you set it up.... I do reccomend you read the android docs like http://developer.android.com/guide/components/intents-filters.html
it will help when asking question and most of the time you wont have to ask cause the answers are there.

Categories

Resources