如何将程序嵌入到android平台特点手机平台上面啊?

android技巧:如何在android程序中执行adb shell命令 - 手机系统 - 编程入门网
android技巧:如何在android程序中执行adb shell命令
package net.gimite.
import java.io.BufferedR
import java.io.FileOutputS
import java.io.IOE
import java.io.InputS
import java.io.InputStreamR
import java.net.HttpURLC
import java.net.MalformedURLE
import java.net.URL;
import net.gimite.nativeexe.R;
import android.app.A
import android.os.B
import android.os.H
import android.view.V
import android.view.View.OnClickL
import android.widget.*;
public class MainActivity extends Activity {
private TextView outputV
private Button localRunB
private EditText localPathE
private Handler handler = new Handler();
private EditText urlE
private Button remoteRunB
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
outputView = (TextView)findViewById(R.id.outputView);
localPathEdit = (EditText)findViewById(R.id.localPathEdit);
localRunButton = (Button)findViewById(R.id.localRunButton);
localRunButton.setOnClickListener(onLocalRunButtonClick);
private OnClickListener onLocalRunButtonClick = new OnClickListener() {
public void onClick(View v) {
String output = exec(localPathEdit.getText().toString());
output(output);
// Process process = Runtime.getRuntime().exec(localPathEdit.getText().toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// Executes UNIX command.
private String exec(String command) {
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) & 0) {
output.append(buffer, 0, read);
reader.close();
process.waitFor();
return output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
private void download(String urlStr, String localPath) {
URL url = new URL(urlStr);
HttpURLConnection urlconn = (HttpURLConnection)url.openConnection();
urlconn.setRequestMethod(&GET&);
urlconn.setInstanceFollowRedirects(true);
urlconn.connect();
InputStream in = urlconn.getInputStream();
FileOutputStream out = new FileOutputStream(localPath);
byte[] buffer = new byte[4096];
while ((read = in.read(buffer)) & 0) {
out.write(buffer, 0, read);
out.close();
in.close();
urlconn.disconnect();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
private void output(final String str) {
Runnable proc = new Runnable() {
public void run() {
outputView.setText(str);
handler.post(proc);
要加入权限
&uses-permission android:name=&android.permission.INTERNET&&&/uses-permission&
源码下载地址:http://download.csdn.net/detail/gshengod/6932845如何把应用程序app编译进android系统 - 无语 - ITeye博客
博客分类:
转载:
http://ywxiao66./blog/static//
------------------------------------------------------------------
把常用的应用程序编译到img文件中,就成了系统的一部分,用户不必自己安装,当然也卸载不了;
同时也可以删减系统自带的应用程序,精简系统;
1.\build\target\product 目录下generic.mk文件:
PRODUCT_PACKAGES := \
AccountAndSyncSettings \
DeskClock \
AlarmProvider \
Bluetooth \
Calculator \
Calendar \
CertInstaller \
DrmProvider \
Gallery3D \
LatinIME \
Launcher2 \
我们添加一个testMid \ 应用名称。
2.把testMid包放入
\packages\apps 目录下,修改android.mk文件。
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := testMid
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
注:LOCAL_PACKAGE_NAME := testMid (包名必须和generic.mk中添加的相同)
编译源码,可以看到在
\out\target\product\smdkv210\system\app
目录下生存了testMid.apk了。这时system.img也包含了此应用。
-------------------------------------------------------------------
特殊情况:有时,应用需要包含jar包,这时的app导入源码时会出现问题:
MODULE.TARGET.JAVA_LIBRARIES.libarity already defined by ... stop
由于 LOCAL_STATIC_JAVA_LIBRARIES := libarity& 会引发错误信息。
目前解决方法是:
\build\core 目录下修改base_rules.mk
注释掉错误信息:
ifdef $(module_id)
#$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
endif
$(module_id) := $(LOCAL_PATH)
--重新编译,这时可以通过了。
& (2)、删除原厂(Telchips)带源码的应用程序,如DTV_DVBT
& 在/device/telechips/m801/device.mk
& 注释掉相应语句:
& # PRODUCT_PACKAGES += \
& #&&& SampleDVBTPlayer \
& 同时,在/out/target/product/m801/system/app 找到相应的.APK包,并删除
浏览: 101957 次
来自: 深圳
原来是要这样子滴,谢谢博主咯!

我要回帖

更多关于 android平台特点 的文章

 

随机推荐