활동의 데이터를 조각으로 전달하려고합니다. 나는 해결책을 둘러 보았지만 이것이 나를 위해 일할 수 없었습니다. 내가 번들을 사용했지만 null 포인터 예외가 발생했습니다.활동에서 조각으로 데이터를 전달하려고 할 때 null 포인터입니다. Android
활동 등급 :
public class RouteOutput extends AppCompatActivity {
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle ways = getIntent().getExtras();
if(ways==null) {
return;
}
System.out.println("START LAT: " + ways.getDouble("start_lat"));
ways.putDouble("start_lat", ways.getDouble("start_lat"));
ways.putDouble("start_lon", ways.getDouble("start_lon"));
ways.putStringArrayList("coords", ways.getStringArrayList("coords"));
if(!(ways.getDouble("altend") == 0)) {
ways.putDouble("altend_lat", ways.getDouble("altend_lat"));
ways.putDouble("altend_lon", ways.getDouble("altend_lon"));
}
FragmentMapOutput frag = new FragmentMapOutput();
frag.setArguments(ways);
그리고 내 조각 클래스의
내가 이것을 가지고 : 나는 안드로이드 tablayout 템플릿을 사용하여이 activty 두 조각을하고View view = inflater.inflate(R.layout.fragment_map_output, container, false);
MapboxAccountManager.start(getContext(), getString(R.string.access_token));
mView = (MapView) view.findViewById(R.id.mapview);
mView.onCreate(savedInstanceState);
mView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mMap = mapboxMap;
Bundle bundle = getArguments();
double startlat = bundle.getDouble("start_lat");
System.out.println("BUNDLE: " + startlat);
.
내가 점점 오전 오류는 다음과 같습니다 :
W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'double android.os.BaseBundle.getDouble(java.lang.String)' on a null object reference
FragmenTransaction은 어떻게 생겼습니까? –
이 솔루션을 사용해보십시오. http://stackoverflow.com/questions/32031178/nullpointerex-x-android-os-bundle –
여기에 전화 코드를 게시 할 수 있습니까 –