0
Android上での私の最初の「のhelloWorld」タイプのアプリを取得し、また、Javaでその患者:)してくださいHTCアンドロイド2.2セルID WCDMA
私はW-CDMAでのセルIDを取得したいので、私はそのアプリを作ります:
package helloWorld.w;
//package com.eepyaj.cellID;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class w extends Activity {
CdmaCellLocation location;
int cellID, lac;
private Context context;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = (Context) this;
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
location = (CdmaCellLocation) tm.getCellLocation();
cellID = location.getBaseStationId();
String tx;
tx = String.valueOf(cellID);
TextView tv = new TextView(this);
tv.setText("Cell ID " + tx);
setContentView(tv);
}
}
は残念ながらメッセージを使用してアプリケーションを終了:
"アプリケーションのhelloWorld(プロセスhelloWorld.w)が予期せず停止しました、もう一度やり直してください。"(HTCにし、エミュレータ上の両方)
私はeclpiseの下でそのアプリを作った、typcial(エミュレータHTCおよびオン)作品「世界のhello」、ので、私はその問題は、任意のヘルプのために、事前にその「セルID」
THXを得ることにあると思い
logcatを 'ddms'でチェックすると、正確なエラーの詳細が表示されます。私は 'tm.getCellLocation()'が 'null 'を返していると言っています。 –
あなたが言ったように - tm.getCellLocation()はヌルをretrunsしますが、なぜ、マニフェストでセットアップのpersmissions:android.permission.ACCESS_COARSE_LOCATION – josiPbros