0

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.

RKD
  • 405
  • 1
  • 5
  • 16
  • Check this link: http://stackoverflow.com/questions/21814825/you-need-to-use-a-theme-appcompat-theme-or-descendant-with-this-activity – Rama Nov 03 '15 at 13:52
  • Possible duplicate of above link – IntelliJ Amiya Nov 03 '15 at 13:55
  • Thanks @Rama ,i have already tried this and this gets executed successfully but the thing is when i change this Class to Activity the layout that has been designed for the AppCompactActivity Class do not get applied properly. Hence i thought if we can do something which might not require any changes in Activity Class. – RKD Nov 03 '15 at 13:57

1 Answers1

1

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.

JstnPwll
  • 8,585
  • 2
  • 33
  • 56