Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
13
Erster Beitrag:
vor 6 Jahren, 1 Monat
Letzter Beitrag:
vor 4 Jahren, 10 Monaten
Beteiligte Autoren:
iso , Georgio , Ruben Sanchez Peña , Alan Evans, Georgio

WM16 Android - Open App from an App SOLVED

Startbeitrag von iso am 09.03.2012 09:25

Hi,

has anyone used this command to fire up another application from within another?

Can t get it to work, maybe i have the incorrect path of the app, can anyone help me with this?

thanks

iso

Antworten:

Re: WM16 Android - ShellExecute

Hi.

When you use the function the application open the document or show you a popup window with the applications can open the documment. The application selection is by extension document file (like Windows for example).


Rubén

von Ruben Sanchez Peña - am 09.03.2012 12:21

Re: WM16 Android - ShellExecute

Hello Ruben,

I can use it in WIndev no problem, but with WM in android i cant get it to open an application.

i have tried this just to see if i can locate the file but each of the below fails:

prog is string = (fCurrentDir()+"/"+ExeInfo(exeName))

Info(prog)

IF fFileExist(prog) THEN
Info("The file named "+ prog +" exists on the disk")
ShellExecute(prog)

ELSE
Info("no")

END

prog2 is string = (ExeInfo(exeName))

Info(prog2)

IF fFileExist(prog2) THEN
Info("The file named "+ prog2 +" exists on the disk")
ShellExecute(prog2)

ELSE
Info("no")

END


thanks

iso

von iso - am 09.03.2012 12:55

Re: WM16 Android - ShellExecute

Hi.

ShellExecute run ana application associated a to a file type

ShellExecute("doc.pdf") will open the Adobe Acrobat to read the pdf file.

If you want execute other program ExeRun isn`t allowed in Android.



Rubén

von Ruben Sanchez Peña - am 09.03.2012 23:22

Re: WM16 Android - ShellExecute

Hi Iso,

You need to write a method in Java:

I wrote a thread about how to do that a while back:
http://27130.foren.mysnip.de/read.php?27131,77739,78393#msg-78393

This is old now but the premise is still the about the same in newer platforms.
In your case, you may also need to check the package manager to see if the app
you want to fire off actually exists on the device. In Android, you can't really search
for application paths (nor do you want to -- confusing!!) If you need help with that
piece, let me know.

Good Luck!
Georgio

von Georgio - am 10.03.2012 03:09

Re: WM16 Android - ShellExecute

Ruben, thanks for that i see what you mean now.

Georgio,

Many thanks for you time on this,much appreciated :)
i have been trying the java method as u suggested but of cause i cant get it to work, this is my method:

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;


public static void openinjava()
{
Intent launch_intent = new Intent("android.intent.action.MAIN");
launch_intent.addCategory("android.intent.category.LAUNCHER");
launch_intent.setComponent(ComponentName.unflattenFromString("com.rsl.certa/com.rsl.certa.CertA"));
startActivity(launch_intent);
}


and this is the error message i get when i try to compile:

Error returned:
src\com\rsl\certa\wdgen\GWDCPONSTART.java:1646: cannot find symbol
symbol : method startActivity(android.content.Intent)
location: class com.com.rsl.certa.wdgen.GWDCPONSTART
startActivity(launch_intent);
^
1 error

am i missing another import? or do i need to enable something so it can find the file/symbol?

many thanks

iso

von iso - am 11.03.2012 08:04

Re: WM16 Android - ShellExecute

Hi Iso,

Try this: (invoking getContext()/getApplicationContext working in WM is
pretty important -- 9 times out of 10, that's prob. your issue)

Keep in mind, may also need a contentResolver (depending on
the app/widget you are trying to fire off). No need for "import android.app.Activity;",
that's done @onCreate().



import android.content.Context;
import android.content.ComponentName;
import android.content.Intent;


public static void openinjava() {

Context context = getApplicationContext();
launch_intent.addCategory("android.intent.category.LAUNCHER");
launch_intent.setComponent(ComponentName.unflattenFromString("com.rsl.certa/com.rsl.certa.CertA"));
context.startActivity(launch_intent);

}


Hope this helps!

Thanks
Georgio

von Georgio - am 11.03.2012 18:31

Re: WM16 Android - ShellExecute

Hi Georgio,

Many thanks for that, i will test tomorrow at the office, i noticed you left this line out though:

Intent launch_intent = new Intent("android.intent.action.MAIN");

iso

von iso - am 11.03.2012 20:40

Re: WM16 Android - ShellExecute

Hi Iso,

Good catch. Sorry, I guess I didn't paste that in to the code block.

Thanks
Georgio

von Georgio - am 12.03.2012 02:40

Re: WM16 Android - ShellExecute

Hi Georgio,

again thanks for you time with this, its getting closer

import android.content.Intent;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;



public static void openinjava()
{
Context context = getApplicationContext();
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.rsl.ps_ec_install", "com.rsl.ps_ec_install.INSTALL_ELEC_PS");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);

}


the only error message i get now is that of the app im trying to launch, it says it cant find it, i ll keep trying and keep posted, going to try and find it on its AndroidManifest.

thanks

iso

von iso - am 12.03.2012 09:34

Re: WM16 Android - ShellExecute

hi,

if anyone interested this is solved now:

this line

final ComponentName cn = new ComponentName("com.rsl.ps_ec_install", "com.rsl.ps_ec_install.XXX");

where XXX is the name and this can be found in its AndroidManifest.xml file, you will need to make a copy of this file while its installing as once the app is installed all its files are deleted




von iso - am 12.03.2012 09:51
Hi iso,

I've just found your thread via a Google Search, I'm using WM18 and can view the Android Manifest just before compilation. Whereabouts do I find the XXX bit in the manifest? My package name on the app to be called is example.test2.main

Many thanks

Alan

von Alan Evans - am 31.05.2013 11:46
Its ok, couldn't see the last couple of lines in your final post when I viewed it from a Google Search! Working now!

Thanks!

von Alan Evans - am 31.05.2013 12:20
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.