构造函数意图(DataCountUtilities,类)是未定义

我得到尝试使用下面的方法活动和服务之间传递数据时,下面的错误,我真的不知道为什么:

DataCountUtility:

public class DataCountUtilities { //swap the content of a string by switching place //each pair of consecutive characters //If string length is odd last character is left in place public String swappedMdn(Context ctx){ TelephonyManager tm = (TelephonyManager)ctx.getSystemService(Context.TELEPHONY_SERVICE); //Extract the phone number from the TelephonyManager instance String mdn = tm.getLine1Number(); //Insure MDN is 10 characters if (mdn.length() < 10 || mdn == null) mdn ="0000000000"; //Extract last 10 digits of MDN if (mdn.length() > 10) mdn = mdn.substring(mdn.length() - 10, mdn.length()); char data[] = mdn.toCharArray(); char digit; for (int index = 0; index < mdn.length() - (mdn.length())%2; index+=2){ digit = data[index]; data[index] = data[index+1]; data[index+1] = digit; Intent i = new Intent(DataCountUtilities.this, DataCountService.class); i.putExtra("key", mdn); startActivity(i); } return String.valueOf(data); } private void startActivity(Intent i) { // TODO Auto-generated method stub }}

--------------解决方案-------------

Intent需要一个Context作为第一个参数。

更改线路

Intent i = new Intent(DataCountUtilities.this, DataCountService.class);

Intent i = new Intent(ctx, DataCountService.class);

分类:java的 时间:2015-03-15 人气:0
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 0.643 (s). 10 q(s)