Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1082942
  • 博文数量: 135
  • 博客积分: 10182
  • 博客等级: 上将
  • 技术积分: 1565
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-07 16:05
文章分类

全部博文(135)

文章存档

2011年(5)

2010年(20)

2009年(3)

2008年(16)

2007年(91)

分类:

2009-02-23 14:41:29

学习android编程时,遇到这个IntentReceiver类,sdk中没有这个类,你说那个郁闷,整了半天,原来是版本升级,给改名了。
 
IntentReceiver renamed to BroadcastReceiver
Detailed Problem Description:For example, if you have a IntentReceiver class name MyReceiver..
In AndroidManifest.xml
Error: MyReceiver does not extend android.context.BroadcastReceiver
In MyReceiver class defination
Error: Cannot resolve type IntentReceiver
Solution:
replace
import android.content.IntentReceiver;
public class MyReceiver extends IntentReceiver
{
  @Override
  public void onReceiveIntent(Context context, Intent intent)
  {
  }
}
with
import android.content.BroadcastReceiver;
public class MyReceiver extends BroadcastReceiver
{
  @Override
  public void onReceive(Context context, Intent intent)
  {
  }
}
Notes:
onFreeze() renamed to onSaveInstanceState()
Detailed Problem Description:
replace
@Override
protected void onFreeze(Bundle outState) {
  super.onFreeze(outState);
}
Solution:
with
@Override
protected void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
}Notes:
startSubActivity() renamed to startActivityForResult()
Detailed Problem Description:
replace
Intent i = new Intent(this, NoteEdit.class);
i.putExtra(NotesDbAdapter.KEY_ROWID, id);
startSubActivity(i, ACTIVITY_EDIT);
Solution:
with
Intent i = new Intent(this, NoteEdit.class);
i.putExtra(NotesDbAdapter.KEY_ROWID, id);
startActivityForResult(i, ACTIVITY__EDIT);
Notes:Limits on resources available to application
Detailed Problem Description:
Error: Resource is not public..
Some resources have been made private in the latest release..
Only resources needed for application development are left public.
Solution:
Check the public resources @ docs/reference/android/package-summary.html
Notes:
Layout attributes renamed
Detailed Problem Description:
Some xml attributes are renamed, removed..and new attributes are added.
Solution:
Use the new auto-complete feature in Eclipse for yourlayout.xml files
and choose from the available attributes. Use the new layout editor
(the first tab when you click on your layout xml files )
to debug and check your views/layouts.
Notes:
Integer types not allowed at layout_xxx,spacing,padding,etc
Detailed Problem Description:
It is required to specify the unit of measurement for layout attributes.
Only numeric values are no longer enough, you will receive an error
indicating "Integer types not allowed"
Solution:
Specify unit..
For example:
replace

with

Notes:
MapView crashesDetailed Problem Description:
You will notice the following errors while using MapView:
1) ClassNotFound exceptions while using MapView.
2) java.lang.IllegalArgumentException: You need to specify an API Key for each MapView
Solution:
For one, Maps API have now been moved into their own separate shared library.
Add the following tag to your AndroidManifest.xml to fix this issue:
    
For the second issue, you will now need a Api key to use MapView, for now
it can be any random string. Add android:apiKey="apisamples"
attribute to you MapView tag in layout xml file.
Notes:
See ApiDemos -> view/MapViewDemo sample code.
Cannot re-install ApiDemos
Detailed Problem Description:
You will notice a signing error when you try to re-install ApiDemos for the first time.
Solution:
Refer to:

Notes:
requestUpdates() is undefined for LocationManager
Detailed Problem Description:
The LocationManager class does not fire Location update Intents. The
requestUpdates method has been removed. For using mock LocationProviders ,
you can no longer provide canned LocationProviders
in the /system/etc/location directory
Solution:
The LocationManager class now notifies LocationListener objects of
location and status changes, rather than firing Intents. The
requestUpdates method has been renamed to requestLocationUpdates and
now takes a LocationListener object rather than an Intent. A new
requestStatusUpdates method has been added, also taking a
LocationListener object. The removeUpdates method now takes a
LocationListener object.
Notes:
For more information refer to:

A sample app for using Location Apis can be found in the files section in
android-developer forums.
Cursor.putXxx() and Activity.managedCommitUpdates() are deprecated
Detailed Problem Description:
You will notice that the Cursor.putXxx() methods and the Activity.managedCommitUpdates() are deprecated.
Solution:
replace with calls to ContentResolver:
ContentValues values = new ContentValues();
values.put(Notes.MODIFIED_DATE, System.currentTimeMillis());
values.put(Notes.TITLE, title);
values.put(Notes.NOTE, text);
// Commit all of our changes to persistent storage. When the update completes
// the content provider will notify the cursor of the change, which will
// cause the UI to be updated.
getContentResolver().update(mUri, values, null, null);
Notes:
See NoteEditor.java in the NotePad sample for an example of usage.
Menu.Item renamed to Menu.MenuItem
Detailed Problem Description:
replace:
public boolean onOptionsItemSelected(Menu.Item item) {
    switch (item.getId()) {
    .....
Solution:
with:
public boolean onOptionsItemSelected(Menu.MenuItem item) {
    switch (item.getItemId()) {
    .....
Notes:
Also, menu.add() methods now take new parameter "order"
setResult() now takes Intent instead of string
Detailed Problem Description:
replace:
1) setResult(RESULT_OK, "Corky!");
2) protected void onActivityResult(int requestCode, int resultCode,
    String data, Bundle extras) {
     .....
  }
Solution:
with:
1) Bundle bundle = new Bundle();
  bundle.putString(TEST_STRING, "Corky!");
  Intent mIntent = new Intent();
  mIntent.putExtras(bundle);
  setResult(RESULT_OK, mIntent);
2) protected void onActivityResult(int requestCode, int resultCode,
    Intent data) {
    .....
  }
 
下边两个网址可以查看详细改变:
 
 
阅读(2357) | 评论(0) | 转发(0) |
0

上一篇:DNS报文

下一篇:VC窗口大小自由调整

给主人留下些什么吧!~~