为什么我的应用程序崩溃?

时间:2014-09-21 15:24:38

标签: android

我正在实施c2call.I跟随他们的教程,但是当我运行应用程序时我的应用程序崩溃。我正在给我的课程和清单。 MyStartupActivity类:

package com.example.c2call;
public class MyStartupActivity extends Activity {

/**
 * Start our main activity. Called if the user was already logged in.
 */
private void startMainActivity() {
    // calls the openMain() method of our MyStartControl
    // --> use StartControl to open the MyMainActivity.
    C2CallSdk.startControl().openMain(this);
    finish();
}

/**
 * Start our login activity. Called if the user was already logged out.
 */
private void startLoginActivity() {
    final Intent intent = new Intent(this, MyLoginActivity.class);
    //added
    intent.putExtra(SCExtraData.BaseFragmentData.EXTRA_DATA_LAYOUT, R.layout.sc_login);
    this.startActivity(intent);
    finish();
}

/**
 * Check if the service is connected and the session is still valid.
 * 
 * @return true if the user already logged in.
 */
private boolean isConnected() {
    return SCCoreFacade.instance().isConnectedToService()
            && SCCoreFacade.instance().isSessionValid();
}

@Override
protected synchronized void onResume() {
    super.onResume();
    try {
        final boolean isConnected = isConnected();
        if (isConnected) {
            startMainActivity();
            return;
        }
        startLoginActivity();
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
}

DemoApp类:

public class DemoApp extends Application {

@Override
public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    String affiliateId = "";
    String secret = "";
    final AffiliateCredentials credentials = new AffiliateCredentials(
            affiliateId, this.getPackageName(), secret);
    C2CallSdk.instance().init(getApplicationContext(), this.getPackageName(),
            credentials);

    C2CallSdk.instance().setStartControl(new MyStartControl());
}

}

MainActivity类:

public class MainActivity extends SCDialpadFragmentActivity{

/*@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
*/
@Override
protected Fragment onCreateFragment() {
    // Create anonymous fragment that derives the
    // default dialpad Fragment and override its onCreateController
    return new SCDialpadFragment() {
        @Override
        protected final IDialpadController onCreateController(final View v,
                final SCViewDescription vd) {
            // Create anonymous subclass of the default dialpad
            // controller.
            return new SCDialpadController(v, vd) {
                // Override the method that is callen when the
                // extrabutton2 button is clicked.
                @Override
                public void onExtraButton2Click(final View v) {
                    // The register button was clicked -> use the
                    // StartContorl to open the Offer Wall.
                    C2CallSdk.startControl().openOfferwall(getContext(),
                            null, R.layout.sc_offerwall,
                            StartType.FragmentActivity);
                }
            };
        }
    };
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onMenuItemSelected(final int featureId, final MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_profile:
        // Open profile activity by using IStartControl
        C2CallSdk.startControl().openProfile(this, null,
                R.layout.sc_edit_profile, StartType.FragmentActivity);
        return true;
    case R.id.menu_exit:
        // Logout from server.
        new Handler().post(new Runnable() {
            @Override
            public void run() {
                C2CallSdk.instance().close(MainActivity.this, false, false,
                        true);
            }
        });
        return true;
    default:
        return super.onMenuItemSelected(featureId, item);
    }
}

/**
 * A placeholder fragment containing a simple view.
 **/
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container,
                false);
        return rootView;
    }
}

}

MyLoginActivity类

public class MyLoginActivity extends SCLoginFragmentActivity {
@Override
protected Fragment onCreateFragment() {
    //add
    int layout=getIntent().getIntExtra(SCExtraData.BaseFragmentData.EXTRA_DATA_LAYOUT, 0);
    return MyLoginFragment.create(layout);
}

}

MyLoginFragment类

public class MyLoginFragment extends SCLoginFragment {

public static MyLoginFragment create() {
    return new MyLoginFragment();
}

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Get reference to register button
    final View registerButton = getActivity().findViewById(
            R.id.sc_login_btn_register);
    // Set an OnClickListener to open the register view if the
    // button was clicked
    registerButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            // The IStartControl within the C2CallSDK singleton
            // provides a convenient method to open the default
            // register activity.
            C2CallSdk.startControl().openRegister(getActivity(), null,
                    R.layout.sc_register, null, StartType.FragmentActivity);
        }
    });
}
}

MyStartControl类:

public class MyStartControl extends SCStartControl{

@Override
public boolean openMain(final Activity activity) {
    // TODO Auto-generated method stub
    Intent intent=new Intent(activity,MainActivity.class);
    activity.startActivity(intent);
    return true;
}       
}

menifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.c2call"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="12"
    android:targetSdkVersion="19" />
<application
    android:name="com.example.c2call.DemoApp"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.c2call.MyStartupActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.c2call.MyLoginActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:label="@null"
        android:theme="@android:style/Theme.Holo.Light" >
    </activity>
    <activity
        android:name="com.example.c2call.MainActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:label="@null"
        android:theme="@android:style/Theme.Holo.Light" >
    </activity>
    <provider
        android:name="com.c2call.sdk.lib.db.provider.C2CallContentProvider"
        android:authorities="com.example.c2call.content"
        android:exported="true"
        android:grantUriPermissions="true" >
        <grant-uri-permission android:pathPattern=".*" />
    </provider>
</application>
</manifest>

logcat的:

09-21 15:44:42.986: W/EGL_emulation(2700): eglSurfaceAttrib not implemented
09-21 15:44:46.462: D/dalvikvm(2700): GC_CONCURRENT freed 122K, 7% free 3162K/3400K, paused 4ms+2ms, total 14ms
09-21 15:44:49.742: D/AndroidRuntime(2700): Shutting down VM
09-21 15:44:49.742: W/dalvikvm(2700): threadid=1: thread exiting with uncaught exception (group=0xa621e908)
   09-21 15:44:49.742: E/AndroidRuntime(2700): FATAL EXCEPTION: main
 09-21 15:44:49.742: E/AndroidRuntime(2700): java.lang.SecurityException: ConnectivityService: Neither user 10081 nor current process has android.permission.ACCESS_NETWORK_STATE.
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at android.os.Parcel.readException(Parcel.java:1425)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at android.os.Parcel.readException(Parcel.java:1379)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:623)
09-21 15:44:49.742: E/AndroidRuntime(2700):     at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:428)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at com.c2call.sdk.lib.m.g.x.d(SourceFile:110)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at com.c2call.sdk.lib.c.f.a.a(SourceFile:90)
09-21 15:44:49.742: E/AndroidRuntime(2700):     at com.c2call.sdk.pub.gui.login.controller.SCLoginController.onButtonLoginClick(SourceFile:32)
09-21 15:44:49.742: E/AndroidRuntime(2700):     at com.c2call.sdk.pub.gui.login.controller.SCLoginController$4.onClick(SourceFile:166)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at android.view.View.performClick(View.java:4204)
09-21 15:44:49.742: E/AndroidRuntime(2700):     at  android.view.View$PerformClick.run(View.java:17355)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at android.os.Handler.handleCallback(Handler.java:725)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at android.os.Handler.dispatchMessage(Handler.java:92)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at android.os.Looper.loop(Looper.java:137)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at android.app.ActivityThread.main(ActivityThread.java:5041)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at java.lang.reflect.Method.invokeNative(Native Method)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at java.lang.reflect.Method.invoke(Method.java:511)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
 09-21 15:44:49.742: E/AndroidRuntime(2700):    at dalvik.system.NativeStart.main(Native Method)

编辑: 当我点击登录按钮时,我的应用程序崩溃。忘记了.logcat。

1 个答案:

答案 0 :(得分:0)

线条清单

的问题
android:name="com.c2call.sdk.lib.db.provider.C2CallContentProvider"

你确定提供的是同一条路吗?

C2CallContentProvider

的包名称是什么