Unable to pass intent parameters and start service when consuming an SDK

  • Replies:2
SistahM1
  • Forum posts: 2

Feb 3, 2017, 2:56:27 PM via Website

I have an Android studio project comprised of two modules: 1. A library I'm developing which has a single class which will be exposed to client apps (MySDK) 2. A test app which will consume methodes within the library. (MyTestApp)

For some reason, when I call the (SomeService) class via an intent with parameters, the parameters are not passed and the class is never invoked. The message I receive in Android Monitor is: "Not able to initialize class for SetValues: java.lang.Class

Also, the issue is not attributed to (SomeService) class. I've already proven this. It may be attributed to how the context is passed since the SDK has no Activity associated with it. But, I'm not sure.

I've tried numerous approaches with out much luck. Any help is greatly appreciated.

//1. MyTestApp (Main Activity)
public class MyTestApp extends AppCompatActivity {

String aUrl =" a url";

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

final TextView mTextView = (TextView) findViewById(R.id.Text);

MySDK mySDK = new MySDK(this.getApplicationContext());
mySDK.retrieveSomethingViaIntentService();

}
}

//2. MySDK
public class MySDK {

private static Context mCtx;

public MySDK(Context context) {
mCtx = context;
}

public void retrieveSomethingViaIntentService(){
Intent i = new Intent(mCtx.getApplicationContext(), SomeService.class);
i.putExtra("Label1", true);
i.putExtra("Label2", false);
mCtx.getApplicationContext().startService(i);
}
}

Reply
JacobVR
  • Forum posts: 14

Feb 9, 2017, 10:17:09 PM via Website

I have an Android studio project comprised of two modules: 1. A library I'm developing which has a single class which will be exposed to client apps (MySDK) 2. A test app which will consume methodes within the library. (MyTestApp)
For some reason, when I call the (SomeService) class via an intent with parameters, the parameters are not passed and the class is never invoked. The message I receive in Android Monitor is: "Not able to initialize class for SetValues: java.lang.Class...Also, the issue is not attributed to (SomeService) class. I've already proven this. It may be attributed to how the context is passed since the SDK has no Activity associated with it. But, I'm not sure.

Reply
SistahM1
  • Forum posts: 2

Feb 9, 2017, 10:38:29 PM via Website

I've resolved the issue.

Reply