Android:将录音机代码与获取和显示用户位置集成时出现问题
我一直在尝试将我非常简单的录音机应用程序与获取当前用户位置并将其显示在屏幕上的功能集成。我希望它在应用程序启动后立即开始搜索位置,但我的代码存在逻辑问题。我仍在学习,但我已经阅读了大量文档和许多不同的教程/示例代码,但似乎没有任何效果。我认为我非常接近我的解决方案,我的录音机应用程序可以工作,但是它与获取用户位置的配合不太好......你们能帮助我吗?非常感谢任何帮助!
这是我的代码(请注意,它可能看起来有点长,但这只是由于额外的间距):
public class AndroidPOIActivity extends Activity implements LocationListener
{
EditText textBoxMessage = null;
private static final String LOG_TAG = "AudioRecordTest";
private static String mFileName = null;
private RecordButton mRecordButton = null;
private MediaRecorder mRecorder = null;
private PlayButton mPlayButton = null;
private MediaPlayer mPlayer = null;
/***************** Record Button ********************/
private void onRecord(boolean start) {
if (start) {
startRecording();
} else {
stopRecording();
}
}
private void startRecording()
{
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
class RecordButton extends Button {
boolean mStartRecording = true;
OnClickListener clicker = new OnClickListener() {
public void onClick(View v) {
onRecord(mStartRecording);
if (mStartRecording) {
setText("Stop recording");
} else {
setText("Start recording");
}
mStartRecording = !mStartRecording;
}
};
public RecordButton(Context ctx) {
super(ctx);
setText("Start recording");
setOnClickListener(clicker);
}
}
/***************** Play Button ********************/
private void startPlaying() {
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(mFileName);
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
private void stopPlaying() {
mPlayer.release();
mPlayer = null;
}
private void onPlay(boolean start) {
if (start) {
startPlaying();
} else {
stopPlaying();
}
}
class PlayButton extends Button {
boolean mStartPlaying = true;
OnClickListener clicker = new OnClickListener() {
public void onClick(View v) {
onPlay(mStartPlaying);
if (mStartPlaying) {
setText("Stop playing");
} else {
setText("Start playing");
}
mStartPlaying = !mStartPlaying;
}
};
public PlayButton(Context ctx) {
super(ctx);
setText("Start playing");
setOnClickListener(clicker);
}
}
/***************** File Saver ********************/
public AndroidPOIActivity() {
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/audiorecordtest.3gp";
}
/***************** On Create ********************/
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
//preparing linear layout
LinearLayout ll = new LinearLayout(this);
//record button
mRecordButton = new RecordButton(this);
ll.addView(mRecordButton,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
//play button
mPlayButton = new PlayButton(this);
ll.addView(mPlayButton,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
TextView locationText = (TextView)this.findViewById(R.id.lblLocationInfo);
ll.addView(locationText,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
//getSystemService(LOCATION_SERVICE);
//setting linear layout
setContentView(ll);
//getting a reference to the system location manager
LocationManager locationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE);
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null)
{
Log.d(LOG_TAG, location.toString());
this.onLocationChanged(location);
}
//defining listener that responds to location updates
LocationListener locationListener = new LocationListener()
{
public void onLocationChanged(Location location)
{
// Called when a new location is found by the network location provider.
makeUseOfNewLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
}
@Override
public void onPause() {
super.onPause();
if (mRecorder != null) {
mRecorder.release();
mRecorder = null;
}
if (mPlayer != null) {
mPlayer.release();
mPlayer = null;
}
}
@Override
public void onProviderDisabled(String arg0)
{
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String arg0)
{
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2)
{
// TODO Auto-generated method stub
}
@Override
public void onLocationChanged(Location location)
{
makeUseOfNewLocation(location);
}
private void makeUseOfNewLocation(Location location)
{
double lon = (double) (location.getLongitude() * 1E6);
double lat = (double) (location.getLatitude() * 1E6);
int lontitude = (int)lon;
int latitude = (int)lat;
Toast.makeText(getApplicationContext(), "New Lontitue = "+ lontitude +"\n New Latitute = "+ latitude, Toast.LENGTH_LONG).show();
}
}
我的代码在清单中也具有权限:
这是我的 main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/lblLocationInfo"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Waiting for location..."/>
<Button android:id="@+id/mRecordButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start Recording"
android:layout_gravity="center"></Button>
<Button android:id="@+id/mPlayButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start Playing"
android:layout_gravity="center"></Button>
</LinearLayout>
Stacktrace: [2011-11-15 14:51:47 - AndroidPOI] ------------------------------------------
[2011-11-15 14:51:47 - AndroidPOI] Android Launch!
[2011-11-15 14:51:47 - AndroidPOI] adb is running normally.
[2011-11-15 14:51:47 - AndroidPOI] Performing org.me.androidpoi.AndroidPOIActivity activity launch
[2011-11-15 14:51:47 - AndroidPOI] Automatic Target Mode: launching new emulator with compatible AVD 'android_2-2'
[2011-11-15 14:51:47 - AndroidPOI] Launching a new emulator with Virtual Device 'android_2-2'
[2011-11-15 14:52:17 - Emulator] emulator: emulator window was out of view and was recentred
[2011-11-15 14:52:17 - Emulator]
[2011-11-15 14:52:36 - AndroidPOI] New emulator found: emulator-5554
[2011-11-15 14:52:36 - AndroidPOI] Waiting for HOME ('android.process.acore') to be launched...
[2011-11-15 14:53:51 - AndroidPOI] HOME is up on device 'emulator-5554'
[2011-11-15 14:53:51 - AndroidPOI] Uploading AndroidPOI.apk onto device 'emulator-5554'
[2011-11-15 14:53:51 - AndroidPOI] Installing AndroidPOI.apk...
[2011-11-15 14:54:27 - AndroidPOI] Success!
[2011-11-15 14:54:27 - AndroidPOI] Starting activity org.me.androidpoi.AndroidPOIActivity on device emulator-5554
[2011-11-15 14:54:29 - AndroidPOI] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.me.androidpoi/.AndroidPOIActivity }
LogCat:
11-15 14:53:19.335: ERROR/Zygote(32): setreuid() failed. errno: 2
11-15 14:53:35.093: ERROR/Zygote(32): setreuid() failed. errno: 17
11-15 14:53:37.553: ERROR/BatteryService(67): usbOnlinePath not found
11-15 14:53:37.553: ERROR/BatteryService(67): batteryVoltagePath not found
11-15 14:53:37.553: ERROR/BatteryService(67): batteryTemperaturePath not found
11-15 14:53:37.603: ERROR/SurfaceFlinger(67): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
11-15 14:53:47.964: ERROR/EventHub(67): could not get driver version for /dev/input/mouse0, Not a typewriter
11-15 14:53:47.964: ERROR/EventHub(67): could not get driver version for /dev/input/mice, Not a typewriter
11-15 14:53:48.414: ERROR/System(67): Failure starting core service
11-15 14:53:48.414: ERROR/System(67): java.lang.SecurityException
11-15 14:53:48.414: ERROR/System(67): at android.os.BinderProxy.transact(Native Method)
11-15 14:53:48.414: ERROR/System(67): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
11-15 14:53:48.414: ERROR/System(67): at android.os.ServiceManager.addService(ServiceManager.java:72)
11-15 14:53:48.414: ERROR/System(67): at com.android.server.ServerThread.run(SystemServer.java:184)
11-15 14:53:49.825: ERROR/SoundPool(67): error loading /system/media/audio/ui/Effect_Tick.ogg
11-15 14:53:49.845: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressStandard.ogg
11-15 14:53:49.845: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressSpacebar.ogg
11-15 14:53:49.857: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressDelete.ogg
11-15 14:53:49.857: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressReturn.ogg
11-15 14:53:52.643: ERROR/ThrottleService(67): Could not open GPS configuration file /etc/gps.conf
11-15 14:53:54.635: ERROR/logwrapper(149): executing /system/bin/tc failed: No such file or directory
11-15 14:53:54.786: ERROR/logwrapper(150): executing /system/bin/tc failed: No such file or directory
11-15 14:53:54.903: ERROR/logwrapper(151): executing /system/bin/tc failed: No such file or directory
11-15 14:54:10.153: ERROR/HierarchicalStateMachine(67): TetherMaster - unhandledMessage: msg.what=3
11-15 14:54:30.744: ERROR/AndroidRuntime(279): FATAL EXCEPTION: main
11-15 14:54:30.744: ERROR/AndroidRuntime(279): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.me.androidpoi/org.me.androidpoi.AndroidPOIActivity}: java.lang.NullPointerException
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.os.Handler.dispatchMessage(Handler.java:99)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.os.Looper.loop(Looper.java:123)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at java.lang.reflect.Method.invokeNative(Native Method)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at java.lang.reflect.Method.invoke(Method.java:521)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at dalvik.system.NativeStart.main(Native Method)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): Caused by: java.lang.NullPointerException
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.view.ViewGroup.addViewInner(ViewGroup.java:1969)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.view.ViewGroup.addView(ViewGroup.java:1865)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.view.ViewGroup.addView(ViewGroup.java:1845)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at org.me.androidpoi.AndroidPOIActivity.onCreate(AndroidPOIActivity.java:169)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): ... 11 more
I have been trying to integrate my very simple voice recorder app with the ability to get the current user's location and display it on the screen. I want it to start searching for the location as soon as the app starts but I have logic problems with my code. I am still learning but I have read through a lot of the documentation and many different tutorials/sample code but nothing seems to work. I think I am very close to my solution, my voice recorder app works however it's not coming along well with getting user's location... can you guys help me? Any help is greatly appreciated!
Here is my code (note it may seem a little long but it's only due to extra spacing):
public class AndroidPOIActivity extends Activity implements LocationListener
{
EditText textBoxMessage = null;
private static final String LOG_TAG = "AudioRecordTest";
private static String mFileName = null;
private RecordButton mRecordButton = null;
private MediaRecorder mRecorder = null;
private PlayButton mPlayButton = null;
private MediaPlayer mPlayer = null;
/***************** Record Button ********************/
private void onRecord(boolean start) {
if (start) {
startRecording();
} else {
stopRecording();
}
}
private void startRecording()
{
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
class RecordButton extends Button {
boolean mStartRecording = true;
OnClickListener clicker = new OnClickListener() {
public void onClick(View v) {
onRecord(mStartRecording);
if (mStartRecording) {
setText("Stop recording");
} else {
setText("Start recording");
}
mStartRecording = !mStartRecording;
}
};
public RecordButton(Context ctx) {
super(ctx);
setText("Start recording");
setOnClickListener(clicker);
}
}
/***************** Play Button ********************/
private void startPlaying() {
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(mFileName);
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
private void stopPlaying() {
mPlayer.release();
mPlayer = null;
}
private void onPlay(boolean start) {
if (start) {
startPlaying();
} else {
stopPlaying();
}
}
class PlayButton extends Button {
boolean mStartPlaying = true;
OnClickListener clicker = new OnClickListener() {
public void onClick(View v) {
onPlay(mStartPlaying);
if (mStartPlaying) {
setText("Stop playing");
} else {
setText("Start playing");
}
mStartPlaying = !mStartPlaying;
}
};
public PlayButton(Context ctx) {
super(ctx);
setText("Start playing");
setOnClickListener(clicker);
}
}
/***************** File Saver ********************/
public AndroidPOIActivity() {
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/audiorecordtest.3gp";
}
/***************** On Create ********************/
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
//preparing linear layout
LinearLayout ll = new LinearLayout(this);
//record button
mRecordButton = new RecordButton(this);
ll.addView(mRecordButton,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
//play button
mPlayButton = new PlayButton(this);
ll.addView(mPlayButton,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
TextView locationText = (TextView)this.findViewById(R.id.lblLocationInfo);
ll.addView(locationText,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
//getSystemService(LOCATION_SERVICE);
//setting linear layout
setContentView(ll);
//getting a reference to the system location manager
LocationManager locationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE);
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null)
{
Log.d(LOG_TAG, location.toString());
this.onLocationChanged(location);
}
//defining listener that responds to location updates
LocationListener locationListener = new LocationListener()
{
public void onLocationChanged(Location location)
{
// Called when a new location is found by the network location provider.
makeUseOfNewLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
}
@Override
public void onPause() {
super.onPause();
if (mRecorder != null) {
mRecorder.release();
mRecorder = null;
}
if (mPlayer != null) {
mPlayer.release();
mPlayer = null;
}
}
@Override
public void onProviderDisabled(String arg0)
{
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String arg0)
{
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2)
{
// TODO Auto-generated method stub
}
@Override
public void onLocationChanged(Location location)
{
makeUseOfNewLocation(location);
}
private void makeUseOfNewLocation(Location location)
{
double lon = (double) (location.getLongitude() * 1E6);
double lat = (double) (location.getLatitude() * 1E6);
int lontitude = (int)lon;
int latitude = (int)lat;
Toast.makeText(getApplicationContext(), "New Lontitue = "+ lontitude +"\n New Latitute = "+ latitude, Toast.LENGTH_LONG).show();
}
}
My code has permissions as well in manifest:
Here is my main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/lblLocationInfo"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Waiting for location..."/>
<Button android:id="@+id/mRecordButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start Recording"
android:layout_gravity="center"></Button>
<Button android:id="@+id/mPlayButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start Playing"
android:layout_gravity="center"></Button>
</LinearLayout>
Stacktrace:
[2011-11-15 14:51:47 - AndroidPOI] ------------------------------
[2011-11-15 14:51:47 - AndroidPOI] Android Launch!
[2011-11-15 14:51:47 - AndroidPOI] adb is running normally.
[2011-11-15 14:51:47 - AndroidPOI] Performing org.me.androidpoi.AndroidPOIActivity activity launch
[2011-11-15 14:51:47 - AndroidPOI] Automatic Target Mode: launching new emulator with compatible AVD 'android_2-2'
[2011-11-15 14:51:47 - AndroidPOI] Launching a new emulator with Virtual Device 'android_2-2'
[2011-11-15 14:52:17 - Emulator] emulator: emulator window was out of view and was recentred
[2011-11-15 14:52:17 - Emulator]
[2011-11-15 14:52:36 - AndroidPOI] New emulator found: emulator-5554
[2011-11-15 14:52:36 - AndroidPOI] Waiting for HOME ('android.process.acore') to be launched...
[2011-11-15 14:53:51 - AndroidPOI] HOME is up on device 'emulator-5554'
[2011-11-15 14:53:51 - AndroidPOI] Uploading AndroidPOI.apk onto device 'emulator-5554'
[2011-11-15 14:53:51 - AndroidPOI] Installing AndroidPOI.apk...
[2011-11-15 14:54:27 - AndroidPOI] Success!
[2011-11-15 14:54:27 - AndroidPOI] Starting activity org.me.androidpoi.AndroidPOIActivity on device emulator-5554
[2011-11-15 14:54:29 - AndroidPOI] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.me.androidpoi/.AndroidPOIActivity }
LogCat:
11-15 14:53:19.335: ERROR/Zygote(32): setreuid() failed. errno: 2
11-15 14:53:35.093: ERROR/Zygote(32): setreuid() failed. errno: 17
11-15 14:53:37.553: ERROR/BatteryService(67): usbOnlinePath not found
11-15 14:53:37.553: ERROR/BatteryService(67): batteryVoltagePath not found
11-15 14:53:37.553: ERROR/BatteryService(67): batteryTemperaturePath not found
11-15 14:53:37.603: ERROR/SurfaceFlinger(67): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
11-15 14:53:47.964: ERROR/EventHub(67): could not get driver version for /dev/input/mouse0, Not a typewriter
11-15 14:53:47.964: ERROR/EventHub(67): could not get driver version for /dev/input/mice, Not a typewriter
11-15 14:53:48.414: ERROR/System(67): Failure starting core service
11-15 14:53:48.414: ERROR/System(67): java.lang.SecurityException
11-15 14:53:48.414: ERROR/System(67): at android.os.BinderProxy.transact(Native Method)
11-15 14:53:48.414: ERROR/System(67): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
11-15 14:53:48.414: ERROR/System(67): at android.os.ServiceManager.addService(ServiceManager.java:72)
11-15 14:53:48.414: ERROR/System(67): at com.android.server.ServerThread.run(SystemServer.java:184)
11-15 14:53:49.825: ERROR/SoundPool(67): error loading /system/media/audio/ui/Effect_Tick.ogg
11-15 14:53:49.845: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressStandard.ogg
11-15 14:53:49.845: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressSpacebar.ogg
11-15 14:53:49.857: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressDelete.ogg
11-15 14:53:49.857: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressReturn.ogg
11-15 14:53:52.643: ERROR/ThrottleService(67): Could not open GPS configuration file /etc/gps.conf
11-15 14:53:54.635: ERROR/logwrapper(149): executing /system/bin/tc failed: No such file or directory
11-15 14:53:54.786: ERROR/logwrapper(150): executing /system/bin/tc failed: No such file or directory
11-15 14:53:54.903: ERROR/logwrapper(151): executing /system/bin/tc failed: No such file or directory
11-15 14:54:10.153: ERROR/HierarchicalStateMachine(67): TetherMaster - unhandledMessage: msg.what=3
11-15 14:54:30.744: ERROR/AndroidRuntime(279): FATAL EXCEPTION: main
11-15 14:54:30.744: ERROR/AndroidRuntime(279): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.me.androidpoi/org.me.androidpoi.AndroidPOIActivity}: java.lang.NullPointerException
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.os.Handler.dispatchMessage(Handler.java:99)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.os.Looper.loop(Looper.java:123)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at java.lang.reflect.Method.invokeNative(Native Method)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at java.lang.reflect.Method.invoke(Method.java:521)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at dalvik.system.NativeStart.main(Native Method)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): Caused by: java.lang.NullPointerException
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.view.ViewGroup.addViewInner(ViewGroup.java:1969)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.view.ViewGroup.addView(ViewGroup.java:1865)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.view.ViewGroup.addView(ViewGroup.java:1845)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at org.me.androidpoi.AndroidPOIActivity.onCreate(AndroidPOIActivity.java:169)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-15 14:54:30.744: ERROR/AndroidRuntime(279): ... 11 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您遇到空指针异常:
我不知道第 169 行在代码中的位置,但请检查一下并确保那里的所有内容都正确。
You're getting a null pointer exception:
I don't know where line 169 is in your code, but check that out and make sure everything is kosher there.
哇,这真的很混乱,试试这个代码:
Wow, this is really muddled try this code: