小编Pal*_*aja的帖子

如何在android中的AsyncTask中使用方法?

在我的应用程序中,我使用JSONwebservice从中获取数据Google Navigation api.我用下面的代码.我得到以下异常

android.os.NetworkOnMainThreadException.

如何使用AsyncTask?这是我的代码.谢谢.public class MainActivity扩展MapActivity {

  MapView mapView ;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    System.out.println("*************1**************1");
    setContentView(R.layout.activity_main);
    System.out.println("*************2**************");
    mapView = (MapView) findViewById(R.id.mapv); 
    System.out.println("*************3**************");



                Route route = directions(new GeoPoint((int)(26.2*1E6),(int)(50.6*1E6)), new GeoPoint((int)(26.3*1E6),(int)(50.7*1E6)));

              RouteOverlay routeOverlay = new RouteOverlay(route, Color.BLUE);
              mapView.getOverlays().add(routeOverlay);
            mapView.invalidate();


    System.out.println("*************4**************");

}



@SuppressLint("ParserError")
private Route directions(final GeoPoint start, final GeoPoint dest) {



    //https://developers.google.com/maps/documentation/directions/#JSON <- get api
    String jsonURL = "http://maps.googleapis.com/maps/api/directions/json?";
    final StringBuffer sBuf = new StringBuffer(jsonURL);
    sBuf.append("origin=");
    sBuf.append(start.getLatitudeE6()/1E6);
    sBuf.append(',');
    sBuf.append(start.getLongitudeE6()/1E6);
    sBuf.append("&destination=");
    sBuf.append(dest.getLatitudeE6()/1E6);
    sBuf.append(',');
    sBuf.append(dest.getLongitudeE6()/1E6);
    sBuf.append("&sensor=true&mode=driving"); …
Run Code Online (Sandbox Code Playgroud)

android google-maps driving-directions

3
推荐指数
1
解决办法
4214
查看次数

如何在Android应用程序中维护以前的屏幕历史?

在我的应用程序中有十个活动.

当我按下后退按钮时,10个屏幕保存了历史记录.但是当我点击下一个按钮时,新屏幕没有任何历史数据.

单击下一步按钮时如何保留历史记录?我的意图代码是

Bundle bundle = getIntent().getExtras();
String Group = bundle.getString("GroupApVehicle");
Intent log = new Intent(EngineCompartment.this, FrontAxle.class);

Bundle bun = new Bundle();
bun.putString("Group", Group);
bun.putString("ECSCORE", _StrpretriScoreCount);
System.out.println("Enginegroup" + Group);
bun.putString("TestIDFA", strtestid);
log.putExtras(bun);
startActivityForResult(log,IPC_ID);
Run Code Online (Sandbox Code Playgroud)

android

1
推荐指数
1
解决办法
745
查看次数

标签 统计

android ×2

driving-directions ×1

google-maps ×1