Using a dagger to enter the database along with gcm, which will extract data from the database

I have a database using GreenDAO and embedded in a dagger application : I use the Dagger to enter my database class into my application, where it stores the sqlited database for the application and performs the usual CRUD functions for objects. I am using GreenDAO for the database.

I have setup and work with GCM . At the same time, for the application, I am Google Cloud Messaging cloud. This includes the GCMIntentService, which extends the Intent Service and configures the service as a service in the manifest file, as well as the GCMBroadcastReceiver, which extends the WakefulBroadcastReceiver and is also configured correctly in the manifest file.

I need to get information from the database when the GCM push message notification appears. . My GCM is working, but after receiving the GCM push notification, I need to access the information from the database. I can get data from the database by explicitly retrieving the sqlited database using the following code:

DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(getApplicationContext(),
                "db-file", null);
db = helper.getWritableDatabase();

While my GCMIntentService can get the application context using getApplicationContext (), I cannot enter my base server.

Do people use DI with GCM? : Is it expected that DI will not be used together with GCM, as there will be situations when the application does not initialize (for example, after installing and first launching and then rebooting the phone), but GCM pushes a notification, and therefore the source code of the database cannot be initialized for use?

: GCMIntentService GCMBroadcastReceiver , , , ( , - )?

+4

All Articles