-
launchMode 屬性的singleInstance 與singleTask類似,只是singleInstance定義的activity會(huì)重新分配一個(gè)棧地址 如圖所示,main1,2,3是mainactivity在棧中的排放,啟動(dòng)方式Main1->FirstActivity->Main2->FirstActivity->Main3,,, 返回時(shí),Main3->Main2->Main1->FirstActivity查看全部
-
<activity android:name="包名.activity" android:process="包名.activity" //開一個(gè)新進(jìn)程 android:launchMode=" " /><activity> lauchMode=1、standard 未指定時(shí)即為standard,在此模式下相同的activity可以重復(fù)創(chuàng)建 2、singleTop 當(dāng)d activity處于棧頂?shù)臅r(shí)候如果再啟動(dòng)d本身不會(huì)再創(chuàng)建一個(gè)新的activity,而是調(diào)用onNewIntent()方法,如果d activity不處于棧頂,被別的activity啟動(dòng)的話仍然會(huì)在棧中重新創(chuàng)建。 3、singleTask 任務(wù)棧中只能存在一次,第二次啟動(dòng)的話就調(diào)用onNewIntent()方法 4、singleInstance查看全部
-
adb shell dumpsys activity 查看當(dāng)前activity, 在打印的log信息中Running activities中查看當(dāng)前打開的activity查看全部
-
通過(guò)在Manifest中為activtiy注冊(cè)信息時(shí)添加:process 即可分配不同的進(jìn)程名; 使用activity的getTaskId()方法可以獲得當(dāng)前應(yīng)用程序的taskId,同一個(gè)應(yīng)用程序下的不同activity默認(rèn)情況下的taskId都是相同的;查看全部
-
bundle傳遞數(shù)據(jù)大于0.5M會(huì)拋出傳輸數(shù)據(jù)過(guò)大異常; 在傳輸大量數(shù)據(jù)的時(shí)候也有可能拋出TransactionTooLargeException異常,解決辦法是減少bundle傳輸?shù)臄?shù)據(jù)量查看全部
-
傳遞一個(gè)bitmap對(duì)象 Intent intent=new Intent(MainActivity.this,SecondActivity.class); Bundle bundle=new Bundle(); Bitmap bitmap=BitmapFactory.decodeResource(getResource(),R.drawable.ic_launcher); bundle.putParcelable("key",bitmap); intent.putExtra(bundle); startActivity(intent); 接收bitmap Intent intent=getIntent(); Bitmap bitmap=intent.getParcelableExtra("key"); imageView.setImageBitmap(bitmap);查看全部
-
如果傳遞數(shù)據(jù)量大的話,可以把數(shù)據(jù)都放在一個(gè)類中 public class Person implements Serializable{ private int age; private String name; private String adress; public Person(int age,String name,String adress){ this.name=name; this.adress=adress; this.age=age; } public String toString(){ //重寫toString方法 return "[name="+name+"age+"+age+"adress+"+adress+" ]" } } 傳入數(shù)據(jù) Intent intent =new Intent(MainActivity.this,SecondActivity.class); Bundle bundle=new Bundle(); Person person=new Person(20,"xiaoming","beijing"); bundle.putSerializable("key",person); intent.putExtras(bundle); startActivity(intent); 接收數(shù)據(jù) Intent intent=getIntent(); Person person=(Person)intent.getSerializableExtra("key");查看全部
-
傳遞數(shù)據(jù) 傳入 Intent intent =new Intent(MainActivity.this,SecondActivity.class); intent.putExtra("key","stringValue"); intent,putExtra("key2",Int); startActivity(intent); 取出 Intent intent =getIntent(); intent.getStringExtra("key"); intent.getIntExtra("key2",0); 通過(guò)Bundle傳遞數(shù)據(jù) 傳入 Intent intent=new Intent(MainActivity.this,SecondActivity.class); Bundle bundle=new Bundle(); bundle.putString("key","stringValue"); bundle.putInt("key2",Int); intent.putExtra(bundle); startActivity(intent); 接收同上查看全部
-
Activity之間傳遞數(shù)據(jù) 1. 傳遞普通數(shù)據(jù) mIntent.putExtra("name", "Hello, xzhang76"); mIntent.putExtra("age", 27); 2. 傳遞Bundle類型數(shù)據(jù) Bundle bundle = new Bundle(); bundle.putString("name", "xzhang76"); bundle.putInt("age", 27); secIntent.putExtras(bundle); 3. 傳遞一個(gè)對(duì)象 要將對(duì)象封裝在Bundle中 Person me = new Person("xzhang76", 27); Bundle bundle = new Bundle(); bundle.putSerializable("person", me); secIntent.putExtras(bundle); 接收的activity中: Person person = (Person) intent.getSerializableExtra("person"); Person這個(gè)類中 public class Person implements Serializable 4. 傳遞一個(gè)Bitmap Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); Bundle bundle = new Bundle(); bundle.putParcelable("bitmap", bitmap); secIntent.putExtras(bundle); 接收的activity中 Bitmap bitmap = intent.getParcelableExtra("bitmap"); 5. 注意Bundle對(duì)象作為載體傳遞數(shù)據(jù)時(shí),數(shù)據(jù)量很?。?lt;0.5M),否則有如下異常拋出: !!! FAILED BINDER TRANSACTION !!! 也就是說(shuō),在Activity之間傳遞數(shù)據(jù)時(shí)一定要注意數(shù)據(jù)不能過(guò)大。查看全部
-
adb shell dumpsys activity查看全部
-
Activity的Task和啟動(dòng)模式查看全部
-
FirstActivity: singInstance,MainActivity: standard 啟動(dòng)時(shí):AMainActivity(id:20)_FristActivity(id:30)_BMainActivity(id:20)_FristActivity(id:30,復(fù)用newIntent)_CMainActivity(id:20) back時(shí):CMainActivity(id:20)_BMainActivity(id:20)_AMainActivity(id:20)_FristActivity(id:30) 總結(jié):?jiǎn)稳蝿?wù)??蓮?fù)用,back不可跨任務(wù)棧查看全部
-
1. 使用intent傳遞普通參數(shù)————》putExtra 2. 使用bundle(map封裝)傳普參 3. 使用bundle傳實(shí)現(xiàn)serializable接口的bean實(shí)例,用bundle.putserial……獲取getSerializable 4. 使用bundle傳遞bitmap,可以用bundle.putParcelable……獲取getParcelable查看全部
-
task(任務(wù))就是activities的序列集合 back stack(后臺(tái)任務(wù)棧)對(duì)activities進(jìn)行一系列的管理、打開、關(guān)閉查看全部
-
bundle傳遞數(shù)據(jù)大于0.5M會(huì)拋出傳輸數(shù)據(jù)過(guò)大異常; 在傳輸大量數(shù)據(jù)的時(shí)候也有可能拋出TransactionTooLargeException異常,解決辦法是減少bundle傳輸?shù)臄?shù)據(jù)量查看全部
舉報(bào)
0/150
提交
取消