0

您好,再次感谢您的回答,但这不是我想要的

这是我单击按钮时出现的错误

45.266:I/Process(442):发送信号。PID:442 SIG:9

这是按钮点击的代码

public void onClick(View v) {

     gps = new NetworkSettings();

     Log.d("error on click ", "here  is the error in the onclick method ");

     if(isGPSEnabled)
     {
     // Log.d("error on click ", "here  is the error in the if statement ");

      Intent intent = new Intent(this, AndroidGoogleMapsActivity.class);
        mContext.startActivity(intent);
     }

     Log.d("error on click ", "here  is the error out the if statement ");



         gps.showSettingsAlert();

}

这是 showSettingsAlert() 方法

public void showSettingsAlert() { alertDialog = new AlertDialog.Builder(mContext);

    Log.d("error on click ", "here  is the error inthe top of the method ");

    // Setting Dialog Title
    alertDialog.setTitle("GPS is settings");

    // Setting Dialog Message
    alertDialog
            .setMessage("GPS is not enabled. Do you want to go to settings menu?");





    // On pressing Settings button
    alertDialog.setPositiveButton("Settings",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(
                            Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                    mContext.startActivity(intent);

                }
            });


    // on pressing cancel button
    alertDialog.setNegativeButton("Cancel",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });


    // Showing Alert Message
    alertDialog.show();
}

我知道错误出现在单击按钮中,但我不知道它是什么以及如何修复它,所以请帮助我

4

2 回答 2

0

寻找它......它可以给你任何想法......

        public Location getLocation() {
    //android.os.Debug.waitForDebugger();
    try {
        locationManager = (LocationManager) mContext
                .getSystemService(LOCATION_SERVICE);

        // getting GPS status
        isGPSEnabled = locationManager
                .isProviderEnabled(LocationManager.GPS_PROVIDER);

        // getting network status
        isNetworkEnabled = locationManager
                .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (isNetworkEnabled) {
            this.canGetLocation = true;
            locationManager.requestLocationUpdates(
                    LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
            Log.d("Network", "Network");
            if (locationManager != null) {
                location = locationManager
                        .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                if (location != null) {
            //      locationManager.removeUpdates(GPSTracker.this);
                    latitude = location.getLatitude();
                    longitude = location.getLongitude();

                }
        //  }
        }

        }
        else if (isGPSEnabled){
            // if GPS Enabled get lat/long using GPS Services
            this.canGetLocation = true;
                locationManager.requestLocationUpdates(
                        LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("GPS Enabled", "GPS Enabled");
                if (locationManager != null) {
                    location = locationManager
                            .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                    if (location != null) {
                    //  locationManager.removeUpdates(GPSTracker.this);
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();

                }
            }
        }
        else{
            //return location;
            this.canGetLocation = false;
        }


    } catch (Exception e) {
        e.printStackTrace();
    }

    return location;
}
于 2012-09-14T20:47:59.753 回答
0
Intent intent = new Intent();
intent.setClass(AndroidGPSTrackingActivity.this, mapslayout.class);
startActivity(intent);

显现:

<uses-library
android:name="com.google.android.maps"
android:required="true" />

像这样使用,错误将得到解决。

于 2013-03-21T09:23:43.733 回答