ac4android
Well-Known Member
Hi,
My app cascades through several activities at the end of which it should display a Google Map with the "From" and "To" points.
Everything works fine until the app tried to execute the intent to display the map, this is the code-snippet that creates the Intent, then starts the activity:
Following is the Java code, I mostly copied from developer.android.com/guide and stackoverflow, but haven't been able to get that working:
The error message:
02-26 00:04:59.990 281-377/system_process E/ThrottleService: problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
QUESTION 1: I do not understand that, what file or directory is Android looking for?
QUESTION 2: Do I need the XML for displaying the map? If so, are there sample codes out there how to set up an XML for maps?
QUESTION 3: How can I coax Android to display amap with the "From" and the "To" points?
My app cascades through several activities at the end of which it should display a Google Map with the "From" and "To" points.
Everything works fine until the app tried to execute the intent to display the map, this is the code-snippet that creates the Intent, then starts the activity:
Code:
// LISTEN to what the user wants... following is what happens if the user clicks on it
@Override
public void onListItemClick(ListView listDeliveriestView,
View itemView,
int position,
long id) {
Intent intent = new Intent(ListDeliveriesActivity.this, ShowMapActivity.class);
intent.putExtra(ListDeliveriesActivity.EXTRA_LISTNO, (int) id); // using a constant makes it easier to retrieve to "send" the data
startActivity(intent);
Following is the Java code, I mostly copied from developer.android.com/guide and stackoverflow, but haven't been able to get that working:
Code:
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
public class ShowMapActivity extends Activity {
protected void showMap(){
// hardcoded for testing purposes, the latitude and longitude comes from another activity
boolean installedMaps = false;
double FROM_LATITUDE = 36.778261;
double FROM_LONGITUDE = -119.417932;
String siteName = "Somewhere in LA";
// Check whether GGoogle Maps is installed
PackageManager pkMgr = getPackageManager();
try{
@SuppressWarnings("unused")
PackageInfo pkInfo = pkMgr.getPackageInfo("com.google.android.apps.maps", 0);
installedMaps = true;
} catch(Exception e) {
e.printStackTrace();
installedMaps = false;
}
//Show the map using the co-ordinates from the checkin
if (installedMaps == true){
String geoCode = "geo:0,0?q="
+ SITE_LATITUDE + ", "
+ SITE_LONGITUDE
+ "(" + siteName + ")";
Intent sendLocationToMap = new Intent(Intent.ACTION_VIEW,
Uri.parse(geoCode));
startActivity(sendLocationToMap);
} else if (installedMaps == false) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ShowMapActivity.this);
// Set the icon, replace the ic_launcher.png with something more meaningful
alertDialogBuilder.setIcon(R.mipmap.ic_launcher);
// Set the Title
alertDialogBuilder.setTitle("Maps not found!");
// Set the message
alertDialogBuilder
.setMessage(R.string.noMapsInstalled) // <=== create an entry in values/string e.g. <string name="noMapsInstalled">No Map Installed</string>
.setCancelable(false)
.setNegativeButton("Got it.",
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id){
dialog.dismiss();
}
});
// Create, then show the alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}
}
02-26 00:04:59.990 281-377/system_process E/ThrottleService: problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
QUESTION 1: I do not understand that, what file or directory is Android looking for?
QUESTION 2: Do I need the XML for displaying the map? If so, are there sample codes out there how to set up an XML for maps?
QUESTION 3: How can I coax Android to display amap with the "From" and the "To" points?