次の方法を使用してアクティビティとサービスの間でデータを受け渡そうとすると、次のエラーが発生します。その理由はよくわかりません。
DataCountユーティリティ:
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
}}