RKD
RKD

Reputation: 431

Intent is not getting passed to AppCompactActivity

Am working on CordovaPlugin creation using Android.

But now am facing an issue where i need some one to address me.

Here is my java code:-

public class MoverMusclePlugin extends CordovaPlugin
{
    @Override
    public boolean execute(String action,final JSONArray args,final CallbackContext callbackContext) throws JSONException
    {
        try
        {
            if(action.equals("set"))
            {
                cordova.getActivity().runOnUiThread(new Runnable() {
                    JSONObject obj = args.getJSONObject(0);
                    Context c = cordova.getActivity().getApplicationContext();
                    @Override
                    public void run() {
                        Intent in = new Intent(c,MoverMusclePage.class);
                        in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        cordova.getActivity().startActivity(in);
                        callbackContext.success();
                    }
                });
                return true;
            }
            else
            {
                callbackContext.error("Invalid Argument");
                return false;
            }
        }
        catch (Exception e)
        {
            callbackContext.error(e.getMessage());
            return false;
        }
    }
}

Now what am doing here is , when every action is equal to 'set' Call the Activity Page using Intent.

But am getting error saying that:-

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pixelmagnus.moveCheck/com.pixelmagnus.moveCheck.MoverMusclePage}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

This is my Activity Class

public class MoverMusclePage extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mover_muscle_page);
    }
}

Please let me know what am doing wrong here.

UPDATE:- Based on the Suggestions give i did change my AppCompactActivity Class to Activity. But then ToolBar is not working.

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);

setSupportActionBar does not applies to ActivityClass.

Upvotes: 0

Views: 477

Answers (1)

JstnPwll
JstnPwll

Reputation: 8685

You need to specify an AppCompat theme to your app. Add android:theme="@style/Theme.AppCompat.Light" (or another AppCompat theme) to your application node in your manifest.

Upvotes: 1

Related Questions