Android笔记——不同apk之间传递参数与数据
Android笔记——不同apk之间传递参数与数据
http://dongyang555-126-com.iteye.com/blog/1308586
android编程的时候,有时候需要在不同的apk之间传递参数或数据,下面是一个简单的例子:
APK(1)的程序代码:
IntentSend.java:
package com.is; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class IntentSend extends Activity { Channel channel = new Channel(); Button szws; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); szws = (Button)findViewById(R.id.szws); szws.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v) { Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putString("channel", channel.channels[0]); intent.setClassName("com.bget", "com.bget.BinderGET"); intent.putExtras(bundle); startActivity(intent); } }); } } Channel.java: package com.is; public class Channel { String channels[] = { "深圳卫视", "深圳电视剧", "深圳都市" }; }
APK(2)的程序代码:
IntentGet.java: package com.ig; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class IntentGet extends Activity { TextView info; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); info =(TextView)findViewById(R.id.info); Bundle bundle = new Bundle(); bundle = this.getIntent().getExtras(); info.setText("现在播放的是:" + bundle.getString("channel")); } }
程序中,主要是调用了Intent和Bundle的方法,Intent程序之间的跳转,Bundle程序之间数据的传递。
好用
相关推荐
yangChong 2020-08-03
zyygive 2020-07-29
yangChong 2020-07-29
绿豆饼 2020-07-28
adb shell cd system/app rm *.apk21. 获取管理员权限: adb root22. 启动Activity: adb shell am start -n 包名/包名+类名。
蓝天梦 2020-07-28
rookieding 2020-07-26
zyygive 2020-06-11
zyygive 2020-06-09
安辉 2020-05-27
KarlMarxs 2020-05-15
xilove0 2020-04-20
laijunfeng 2020-04-07
KarlMarxs 2020-02-23
Soinice 2020-02-18
zyygive 2020-02-17
ProgrammerFan00 2020-02-16
Ubuntu黑客 2020-02-14
89590098 2020-02-01