为了账号安全,请及时绑定邮箱和手机立即绑定

Android-深入Activity

难度初级
时长 1小时16分
学习人数
综合评分9.63
47人评价 查看评价
9.8 内容实用
9.5 简洁易懂
9.6 逻辑清晰
  • singleTop模式下,当Activity处于栈顶时,再跳转到自己时,不会重新创建Activity,会调用onNewIntent()方法。standard模式下,当Activity处于栈顶时,再跳转到自己时,会重新创建一个Activity,调用onCreate()方法。
    查看全部
  • 在配置文件中给Activity 添加launchMode属性,设置Activity启动模式
    查看全部
  • Activity的启动模式
    查看全部
  • 查看任务栈曾经运行过的程序
    查看全部
  • adb shell dumpsys activity 查看Activity任务栈的命令
    查看全部
  • adb shell dumpsys activity 查看
    查看全部
  • 在配置文件中给Activity设置process属性,可以使其打开在另一个进程中,虽然进程不同,但是在同一个Task(任务栈)中 getTaskId()得到本Activity所在任务(栈)的id
    查看全部
  • Activity的Task和启动模式
    查看全部
  • 传递Bitmap对象<br> Intent intent = new Intent(---,---);<br> Bundle bundle = new Bundle();<br> Bitmap bitmap = BitampFactory.decodeResource(getResoruces(),R.drawable.ic_launch);<br> bundler.putParcelable("bitmap",btimap);<br> intent.putExtras(bundle);<br> startActivity(intent);<br> 接收数据 Intent intent=getIntent(); if(intent!=null){ Bitmap bitmap=intent.getParcelableExtra("bitmap"); imageView.setImageBitmap(bitmap); }
    查看全部
  • ==对数据进行封装,传递Java Bean对象===<br> >>1:写一个Person类并实现接口Serializable()序列化类<br> private int age;<br> private String name;<br> private String address;<br> public Person(int age, String name, String address){<br> this.age = age;<br> this.address = address;<br> this.name = name;<br> }<br> public String toString() {<br> return "[name = "+name +"aget = "+age+ "address = "+address+"]";<br> }<br> <br> >>2:ThreeActivity--> onCreate put <br> Intent intent = new Intent(ThreeActivity.this, FourActivity.class);<br> Person person = new Person(1, "ailer", "plws");<br> Bundle bundle = new Bundle();<br> bundle.putSerializable("person", person);<br> intent.putExtras(bundle);<br> startActivity(intent);<br> <br> >>3:In FourActivity-->onCreate put<br> private TextView textView;<br> textView = (TextView)findViewById(R.id.textView);<br> Intent intent = getIntent();<br> if(intent !=null )<br> {<br> Person person = (Person)intent.getSerializableExtra("person");<br> textView.setText(person.toString());<br> }
    查看全部
  • 通过bundle进行数据传递<br> Intent intent = new Intent(---,---);<br> Bundle bundle = new Bundle();<br> bundle.putString("name","nate");<br> bundle.putInt("age",23);<br> intent.putExtras(bundle);<br> startActivity(intent);<br>
    查看全部
  • 传递简单的数据<br> ThreeActivity 传递数据<br> <br> Intent intent = new Intent(ThreeActivity.this,FourActivity.class);<br> intent.putExtra("name","nate");<br> intent.putExtra("age",23);<br> startActivity(intent);<br> <br> FourActivity 接收数据 Intent intent=getIntent(); if(intent!=null){ String name = intent.getStringExtra("name"); int age=intent.getIntExtra("age",0); }
    查看全部
  • ===========对于稍微多一点的数据进行封装================ >>1:写一个Person类并实现接口Serializable()序列化类 private int age; private String name; private String address; public Person(int age, String name, String address){ this.age = age; this.address = address; this.name = name; } public String toString() { return "[name = "+name +"aget = "+age+ "address = "+address+"]"; } >>2:ThreeActivity--> onCreate put Intent intent = new Intent(ThreeActivity.this, FourActivity.class); Person person = new Person(1, "ailer", "plws"); Bundle bundle = new Bundle(); bundle.putSerializable("person", person); intent.putExtras(bundle); startActivity(intent); >>3:In FourActivity-->onCreate put private TextView textView; textView = (TextView)findViewById(R.id.textView); Intent intent = getIntent(); if(intent !=0 ) { Person person = (Person)inten.getSerializableExtra("person"); textView.setText(person.toString()); }
    查看全部
  • ====利用Activity数据交互一定程度控制了数据的产生 >>1:ThreeActivity--> onCreate put Intent intent = new Intent(ThreeActivity.this, FourActivity.class); intent.putExtra("name", "ailer")' intent.putExtra("age", 19); startActivity(intent); 或者利用bundle Intent intent = new Intent(ThreeActivity.this, FourActivity.class); Bundle bundle = new Bundle(); bundle.putString("name", "ailer"); bundle.putInt("age", 18); intent.putExtras(bundle); startActivity(intent); >>2:In FourActivity-->onCreate put private TextView textView; textView = (TextView)findViewById(R.id.textView); Intent intent = getIntent(); if(intent !=0 ) { String name = intent.getStringExtra("name"); int age = intent.getIntExtra("age",0); textView.setView("name = "+name+ " age = "+age); }
    查看全部
  • bundle传递数据不能太大
    查看全部

举报

0/150
提交
取消
课程须知
需要学完<<Android-重识Activity>>
老师告诉你能学到什么?
Activity的Task和Back Stack Activity启动模式 Activity之间的数据交换 Activity之间传递大数据的问题

微信扫码,参与3人拼团

意见反馈 帮助中心 APP下载
官方微信
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!