Reputation: 627
I was a given a module that I have to integrate on the application that I'm currently doing. But I am sort of lost when I encountered a class that extends an Application. What I'm trying to do is to pass intent to that class when a button is clicked. But I get an error in my manifest when I include the class. Probably because it is extending Application, not an Activity. My question is, is it possible to pass intent to a class extending Application? I'm new to java and android so forgive me if this is a stupid question.
Here's my manifest:
<activity
android:name=".RestIntent"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Here's the RestIntent class:
public class RestIntent extends Application {
@Override
public void onCreate(){
super.onCreate();
SalesforceSDKManager.initNative(getApplicationContext(), new KeyImpl(), MainIntent.class);
}
}
Upvotes: 0
Views: 501
Reputation: 12167
change your Application
to Activity
, if there are some methods to implement for the Application
, create a delegate to your application in Activity
.
public class RestIntent extends Activity {
private Application application;
@Override
public void onCreate(){
super.onCreate();
application = getApplication;
SalesforceSDKManager.initNative(getApplicationContext(), new KeyImpl(), MainIntent.class);
}
}
Upvotes: 0
Reputation: 12534
My question is, is it possible to pass intent to a class extending Application?
No, it is not. See: http://developer.android.com/reference/android/content/Intent.html
Intents are received by Activities, BroadcastReceivers and Services, but not by Application objects.
Upvotes: 1