- 浏览: 81026 次
- 性别:
- 来自: 北京
最新评论
-
sunsenzhen:
线程用过不释放吗?
android多线程开发 -
grandkingwang:
...
android 文件上传(模拟表单提交) -
fategaga:
这是多线程么?
android多线程开发 -
zymsuper:
xmpp 的连接方式是 长连接吗?如果是,那和你之前写的第三种 ...
android实现推送实践 -
hyee:
哥们,你那个存储过程是基于哪个数据库的,据我所知Oracle的 ...
连载三:模拟JavaEye论坛首页存储过程
首先定义一个主布局文件
hello_activity.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/cust_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/btn" android:textColor="@android:color/white" android:textSize="28sp" /> <!-- 中间动态加载View --> <ScrollView android:id="@+id/containerBody" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:measureAllChildren="true" > </ScrollView> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="@android:color/black" android:orientation="horizontal" > <!-- 功能模块按钮1 --> <Button android:text="@string/btn" android:id="@+id/btnModule1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:layout_marginLeft="7dp" android:layout_marginTop="3dp" /> <!-- 功能模块按钮2 --> <Button android:text="@string/btn" android:id="@+id/btnModule2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:layout_marginLeft="7dp" android:layout_marginTop="3dp" /> <!-- 功能模块按钮3 --> <Button android:text="@string/btn" android:id="@+id/btnModule3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:layout_marginLeft="7dp" android:layout_marginTop="3dp" /> </LinearLayout> </LinearLayout>
HelloActivity.java
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.helloactivity; import android.view.View; import android.content.ComponentName; import android.content.Intent; import android.widget.Button; import android.widget.ScrollView; //import android.media.MediaScanner; @hide import android.media.MediaPlayer; import android.app.Activity; import android.app.ActivityGroup; import android.app.ProgressDialog; import android.os.Bundle; import android.os.SystemClock; import android.graphics.Paint; import android.os.Handler; import android.widget.Toast; import android.util.Log; public class HelloActivity extends ActivityGroup { //am start -n com.cmcc.mbbms/com.cmcc.mbbms.MainActivity private ScrollView container = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 隐藏标题栏 // requestWindowFeature(Window.FEATURE_NO_TITLE); // 设置视图 setContentView(R.layout.hello_activity); container = (ScrollView) findViewById(R.id.containerBody); // 模块1 Button btnModule1 = (Button) findViewById(R.id.btnModule1); btnModule1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { container.removeAllViews(); Intent intent = new Intent(); ComponentName comp = new ComponentName( "com.cmcc.mbbms", "com.cmcc.mbbms.MainActivity"); intent.setComponent(comp); container.addView(getLocalActivityManager().startActivity( "Module1", intent) .getDecorView()); } }); // 模块2 Button btnModule2 = (Button) findViewById(R.id.btnModule2); btnModule2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { container.removeAllViews(); Intent intent = new Intent(); ComponentName comp = new ComponentName( "com.android.calendar", "com.android.calendar.MonthActivity"); intent.setComponent(comp); container.addView(getLocalActivityManager().startActivity( "Module2", intent) .getDecorView()); } }); // 模块3 Button btnModule3 = (Button) findViewById(R.id.btnModule3); btnModule3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { container.removeAllViews(); Intent intent = new Intent(); ComponentName comp = new ComponentName( "com.android.soundrecorder", "com.android.soundrecorder.SoundRecorder"); intent.setComponent(comp); container.addView(getLocalActivityManager().startActivity( "Module3", intent) .getDecorView()); } }); } }
ActivityGroup 为什么不能启动一个其他进程的Activity
解决方法:
1、在activityThread.java的代码里添加对安全忽略即可。
r.packageInfo = getPackageInfo(aInfo.applicationInfo,
Context.CONTEXT_INCLUDE_CODE + Context.CONTEXT_IGNORE_SECURITY);
2、
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:sharedUserId="com.android.activitygrouptest"
android:versionName="1.0">
设定sharedUserId一致就可以了,这样两个apk会加载到同一个process中运行,同时要把你要启动的activity launchemode 设定为singletop。
只能启动同一个进程的Actvity Intent intent = new Intent(HelloActivity.this,HelloActivity1.class);
public class HelloActivity2 extends ActivityGroup { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //动态添加按钮 LinearLayout tp = new LinearLayout(this); LayoutParams ltp = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT); Button btn = new Button(this); btn.setWidth(100); btn.setText("HelloActivity2"); tp.addView(btn,ltp); this.setContentView(tp); } }
发表评论
-
android 跨进程访问service方法
2012-11-12 19:31 21931.Intent 启动service Activity方法集合 ... -
android画图-解锁界面
2012-11-13 22:43 2266锁屏 Launcher 输入法 应用程序开发 ... -
查询应用使用次数
2012-11-13 22:43 1921http://www.eoeandroid.com/fo ... -
分析Http请求头获取爱帮公交数据
2012-10-20 20:43 2718爱帮公交公布了自己的openAPI,但是之前自己不知道,就通 ... -
android 文件上传(模拟表单提交)
2012-10-15 22:52 15301package irdc.ex08_11; imp ... -
framework新增native方法,aidl,新类,新模块
2012-09-18 16:30 5012如何向android的framework里添加新类 goog ... -
android开机启动流程说明
2012-09-12 14:08 1498第一步:启动linux 1.Bootloader ... -
android多线程开发
2012-08-31 12:22 74481.onResume()完全执行结束了(没有阻塞)的时候才会 ... -
FM 代码详解非原生
2012-09-21 23:40 3097FM点击关机按钮的时候: FMplay.java : ... -
Spreadtrum_Android_8805和8810环境搭建和源码编译V1.0.1_Word文档
2012-08-25 10:01 1648目 录 附录A 修改 ... -
adb问题汇总
2012-07-26 09:50 8126adb shell ps |grep "music| ... -
android Socket编程
2012-03-02 00:13 1113server: import java.net.*; ... -
android实现推送实践
2012-02-04 12:23 2112首先感谢 Android推送通 ... -
第一个iphone应用程序
2011-08-04 16:03 1083暑期实习已经 ... -
android http通信(二) 英译汉字典实例探究网络通信三种方法
2011-06-07 09:12 1442方法一:HttpURLConnection Stri ... -
android http通信(一) HttpURLConntection
2011-06-05 18:32 1154举例:从网络上下载图片 String urlpath=&qu ...
相关推荐
TabActivity已经被废除,而使用ActivityGroup 代替TabActivity,能够更加自由灵活,少很多限制和依赖!
实现了一个精美的底部导航栏,使用fragment替代了过时的activitygroup和tabactivity。里面有详细的注释,解释了每一步为什么要这么操作。相信每一个coder都能看明白。
android中tabhost和ActivityGroup的组合使用,特别是对多个Activity之间的跳转,压栈出战的管理,很有帮助。
其中也包括了TabActivity去实现的,TabActivity 里面每个选项卡里面会有个默认的界面,但是当你的应用这个模块里面不止是一个界面,并且第二个界面里面,还需要你去显示下面的选项卡,很多人都会用到ActivityGroup,...
Android源码——TabHost内嵌ActivityGroup界面管理源码_new_17.7z
Android基于ActivityGroup项目框架,此框架和tabActivity不一样,每个tab下都可以建立多个Activity。
读者也许会马上想到使用TabHost 与 TabActivity的组合,其实最常用的不是它们,而是由GridView与ActivityGroup的组合。每当用户在GridView选中一项,ActivityGroup就把该项对应的Activity的Window作为View添加到...
此为示例代码,详细讲解请参考: http://blog.csdn.net/guolin_blog/article/details/13171191 如对资源内容有疑问,请到博客里留言。
ActivityGroup|顶部底部均有Tab标签之二 http://blog.csdn.net/geofferysun/article/details/41852605
读者也许会马上想到使用TabHost 与 TabActivity的组合,其实最常用的不是它们,而是由GridView与ActivityGroup的组合。每当用户在GridView选中一项,ActivityGroup就把该项对应的Activity的Window作为View添加到...
其中也包括了TabActivity去实现的,TabActivity 里面每个选项卡里面会有个默认的界面,但是当你的应用这个模块里面不止是一个界面,并且第二个界面里面,还需要你去显示下面的选项卡,很多人都会用到ActivityGroup,...
自定义菜单布局+ActivityGroup+多个Activity的方式实现仿新浪微博底部菜单更新UI) 详解:http://blog.csdn.net/pocoyoshamoo/article/details/24708715
实现TabHost有三种方式:继承自TabActivity,ActivityGroup和自定义的Activity 实现 备注:我在继承TabActivity的时候,将TabWidget的android:layout_height设置为"fill_parent"时,tab中不显示任何东西。如图: ...
分页大家都会用Android的TabHost和TabActivity的组合,今天我这里实现的是GridView和ActivityGroup实现的分页,这里需要将Activity转换成Window,然后再换成成View添加到容器中,效果如下 1.布局文件底部放一个...
Fragment应用实战案例,联系使用Android中的fragment,替换TabActivity,ActivityGroup;更多详细内容请访问 http://blog.csdn.net/qq_20889581/article/details/50407863 阅读浏览
Android底部标签页的代码例子,提供了三种实现方式,分别是:使用TabActivity实现、使用ActivityGroup实现、使用FragmentActivity实现。
Fragment,通过Api可以发现原来使用用于构建普通应用程序的框架的一些类,比如TabActivity,ActivityGroup都已经不推荐使用了,转而替换成Fragment。继承FragmentActivity
CamMoniter,Snake,ActivityGroup,Android Emulater,Android的ADB工具的使用,Animation_Activity,Animation_Demo,Camera_Demo1,CameraTest. Download_Demo,DemoGeneralForm,SpashScreen,ViewFlipperDemo, ...
包括 android页面左右滑动(采用android-support-v4.jar 中的 fragment来替换 4.0已经废弃的 TabActivity、ActivityGroup等)、检测GPS定位是否打开、network是否可用、控件加载异步图片等等 希望对您初期项目搭建...
在一个主界面中做Activity切换一般都会用TabActivity,使用方便,Activity互相之间相对独立,但是可定制性不强,而且修改起来很麻烦。当然也可以把layout分开,把逻辑代码全写在主界面的逻辑代码中,但是很明显可...