从一个Activity更改为另一个Activity时,Java Binding错误

时间:2016-06-14 16:07:17

标签: java android

Java绑定错误从一个Activity更改为另一个Activity时。

06-14 21:16:55.984 16245-16245/com.android.bhavin04.ganeshutsavmumbai E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!
06-14 21:16:55.984 16245-16260/com.android.bhavin04.ganeshutsavmumbai I/art: Background sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 92MB/92MB, paused 26.442ms total 1.036s
06-14 21:16:56.019 16245-16245/com.android.bhavin04.ganeshutsavmumbai E/AndroidRuntime: Error reporting crash
                                                                                        android.os.TransactionTooLargeException
                                                                                            at android.os.BinderProxy.transactNative(Native Method)
                                                                                            at android.os.BinderProxy.transact(Binder.java:496)
                                                                                            at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4208)
                                                                                            at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:89)
                                                                                            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                                                                                            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
06-14 21:16:56.019 16245-16245/com.android.bhavin04.ganeshutsavmumbai I/Process: Sending signal. PID: 16245 SIG: 9

主要活动: -

public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback {

    private GoogleMap mMap;
    private android.support.v7.widget.Toolbar toolbar;
    private LatLngBounds Mumbai = new LatLngBounds(
            new LatLng(-44, 113), new LatLng(19.075984, 72.877656));


    @Override
    protected void onCreate(Bundle savedInstanceState) {


        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);

        toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); // Attaching the layout to the toolbar object
        setSupportActionBar(toolbar);
        // Setting toolbar as the ActionBar with setSupportActionBar() call
        Pushbots.sharedInstance().init(this);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);


    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    /**
     * On menu item selected
     */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // toggle nav drawer on selecting action bar app icon/title

        if (onOptionsItemSelected(item)) {
            return true;
        }
        // Handle action bar actions click
        switch (item.getItemId()) {
            case R.id.action_settings:
                // Selected settings menu item
                // launch Settings activity
                Intent intent1 = new Intent(MapsActivity.this,
                        Settings.class);
                startActivity(intent1);
                return true;
           /* case R.id.action_favorite:
                // Selected settings menu item
                // launch Settings activity
                Intent intent1 = new Intent(MapsActivity.this,
                        Settings.class);
                startActivity(intent1);
                return true;*/
            default:
                return super.onOptionsItemSelected(item);
        }

    }

    @Override
    public void onMapReady(GoogleMap googleMap) {

        mMap = googleMap;
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(Mumbai.getCenter(), 14));

        if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

            return;
        }
        // mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
        mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        mMap.setMyLocationEnabled(true);
        mMap.setTrafficEnabled(true);

        LatLng Mumbai = new LatLng(19.075979, 72.879696);
        mMap.moveCamera(CameraUpdateFactory.newLatLng(Mumbai));


        // Add a marker in Sydney and move the camera
        LatLng lic = new LatLng(19.180140, 72.947569);
        mMap.moveCamera(CameraUpdateFactory.newLatLng(lic));
        mMap.addMarker(new MarkerOptions().position(lic).title("Lic colony ganeh utsav"));


        // LOCATION POP UP
// Get Location Manager and check for GPS & Network location services
        LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
        if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER) ||
                !lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
            // Build the alert dialog
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("Please Check Location Services is Active");
            builder.setMessage("Please enable Location Services and GPS");
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                    // Show location settings when the user acknowledges the alert dialog
                    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                    startActivity(intent);
                }
            });
            Dialog alertDialog = builder.create();
            alertDialog.setCanceledOnTouchOutside(false);
            alertDialog.show();
        }


    }


}

我的清单: -

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.bhavin04.ganeshutsavmumbai">

    <!--
        Pushbot permission start
    -->

    <!-- GCM connects to Google Services. -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <permission
        android:name="com.android.bhavin04.ganeshutsavmumbai.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.android.bhavin04.ganeshutsavmumbai.permission.C2D_MESSAGE" />
    <!-- This app has permission to register and receive dataf message. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <!--
        Pushbot permission end
    -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application

        android:allowBackup="true"
        android:icon="@drawable/app_ic"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar">

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name="com.android.bhavin04.ganeshutsavmumbai.Settings"
            android:label="@string/app_name" />
        <activity

            android:name=".SplashScreen"
            android:label="@string/app_name">


            <intent-filter>
                <action android:name="com.android.bhavin04.ganeshutsavmumbai.MESSAGE" />
                <category android:name="android.intent.category.DEFAULT" />
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>
        <!--
Pushbot permission start
-->
        <activity
            android:name="com.android.bhavin04.ganeshutsavmumbai.MapsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />

        <receiver
            android:name="com.pushbots.google.gcm.GCMBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <!-- Receives the actual messages. -->
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <!-- Receives the registration id. -->
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.android.bhavin04.ganeshutsavmumbai" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.pushbots.push.DefaultPushHandler" />

        <service android:name="com.pushbots.push.GCMIntentService" />
        <!--
Pushbot permission end
-->

    </application>

</manifest>

构建Gradle: -

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"


    defaultConfig {
        applicationId "com.android.bhavin04.ganeshutsavmumbai"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.pushbots:pushbots-lib:2.0.13@aar'

    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services:9.0.2'
}

我们将不胜感激。在切换活动时,我的应用程序突然关闭。我使用过谷歌地图Api

1 个答案:

答案 0 :(得分:0)

如果您只是使用Google maps服务,请尝试将compile 'com.google.android.gms:play-services:9.0.2'更改为compile 'com.google.android.gms:play-services-maps:9.0.2'