PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV Mobile 2024
→
Intent JAVA vers application Terminal Emulator
Intent JAVA vers application Terminal Emulator
Started by soita, Jun., 21 2017 1:05 PM - 2 replies
Connect yourself…
soita
#1
Posted on June, 21 2017 - 1:05 PM
Bonjour à tous,
Je souhaite pouvoir exécuter une ligne de commande shell directement via un Intent comme le propose le créateur de l'application sur son wiki :
https://github.com/jackpal/Android-Terminal-Emulator/wiki/Launching-Terminal-Emulator-for-Android-from-another-App
Voici ce que je souhaite utiliser selon son exemple :
// opens a new window and runs "echo 'Hi there!'"
// application must declare jackpal.androidterm.permission.RUN_SCRIPT in manifest
Intent i = new Intent("jackpal.androidterm.RUN_SCRIPT");
i.addCategory(Intent.CATEGORY_DEFAULT);
i.putExtra("jackpal.androidterm.iInitialCommand", "echo 'Hi there!'");
startActivity(i);
Gradle me retourne une erreur de type Symbol en me montrant une flèche sous le s de stratActivity(i) ??????????
Pourriez-vous m'éclairer s'il vous plait ?
Report
0
0
JeAn-PhI
#2
Posted on June, 21 2017 - 2:38 PM
soita a utilisé son clavier pour écrire :
Bonjour à tous,
Je souhaite pouvoir exécuter une ligne de commande shell directement via un
Intent comme le propose le créateur de l'application sur son wiki :
https://github.com/jackpal/Android-Terminal-Emulator/wiki/Launching-Terminal-Emulator-for-Android-from-another-App
Voici ce que je souhaite utiliser selon son exemple :
// opens a new window and runs "echo 'Hi there!'"
// application must declare jackpal.androidterm.permission.RUN_SCRIPT in
manifest
Intent
i
=
new
Intent
(
"jackpal.androidterm.RUN_SCRIPT"
)
;
i.addCategory
(
Intent.CATEGORY_DEFAULT
)
;
i.putExtra
(
"jackpal.androidterm.iInitialCommand"
,
"echo 'Hi there!'"
)
;
startActivity
(
i
)
;
Gradle me retourne une erreur de type Symbol en me montrant une flèche sous
le s de stratActivity(i) ??????????
Pourriez-vous m'éclairer s'il vous plait ?
essayez en ajoutant ceci :
Activity act = getActiviteEnCours();
act.startActivity(i);
--
Cordialement JeAn-PhI
Report
0
0
Philippe Pasquali
#3
Registered member
945 messages
Popularité : +102 (110 votes)
Posted on June, 21 2017 - 9:02 PM
Bonjour
Cette petite fonction java à mettre en procédure globale de type java devrait répondre à votre besoin
// Exécute une commande avec le shell
// Exemples :
// ShellExecute("service list")
// ShellExecute("service check phone")
// ShellExecute("ls /system")
// ShellExecute("date")
// ShellExecute("ps")
// ShellExecute("logcat -g")
// ShellExecute("logcat -d")
import java.lang.Runtime;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public static String ShellExecute(String pCommand)
{
StringBuffer output = new StringBuffer();
String response = "";
String line = "";
Process p;
try {
p = Runtime.getRuntime().exec(pCommand);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = reader.readLine())!= null) {
response += line + "\r\n";
}
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
Report
1
0
→ Go back to WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
WEBDEV (earlier versions)
WINDEV Mobile (earlier versions)
Reports & Queries
Off-topic
Tools
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text