"Uses or overrides a deprecated API" in android compiling.

本文探讨了在使用Eclipse开发Android应用程序时遇到的“使用或覆盖废弃API”警告问题。通过一个具体的示例代码片段,展示了如何识别并解决这类警告,以确保应用能够顺利构建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Sometimes we write android apps with eclipse and generate apks normally, but put the apks' package in base for entire build, we get the warning/error "uses or overrides a deprecated API", then quit the building.

 

A deprecated API is an API or part of API that is not officially supported anymore, the compiler will check for it and throw the warning/error then.

 

Here we should manage our APIs.

i.e.

 

 

btn.setOnClickListener(new View.OnClickListener(){

			public void onClick(View v) {
				// TODO Auto-generated method stub
				ActivityManager am = (ActivityManager)cnx.getSystemService(Context.ACTIVITY_SERVICE);
				ComponentName cn = am.getRunningTasks(1).get(0).topActivity;
				String des = (String)am.getRunningTasks(1).get(0).description;
				bmp = am.getRunningTasks(1).get(0).thumbnail;
				
				Log.i("SnapshotDemo","bmp = "+bmp+"/ncn = "+cn+"/ndes = "+des);
			}
        	
        });
 

Android recommend to use new View.OnClickListener ()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值