Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Krishna Vemulavada
/
vera_2.1_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
aa91bb6f
authored
Oct 12, 2019
by
Simhachalam ch
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
changed service to Job Service to avoid crash in android 8.0 versions
parent
708eda49
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
18 deletions
app/build.gradle
app/src/main/AndroidManifest.xml
app/src/main/java/com/vsoft/vera/CatalogueApplication.java
app/src/main/java/com/vsoft/vera/service/SyncService.java
app/build.gradle
View file @
aa91bb6f
...
@@ -36,7 +36,7 @@ android {
...
@@ -36,7 +36,7 @@ android {
defaultConfig
{
defaultConfig
{
applicationId
"com.vsoft.vera"
applicationId
"com.vsoft.vera"
minSdkVersion
2
1
minSdkVersion
2
3
targetSdkVersion
28
targetSdkVersion
28
versionCode
1
versionCode
1
versionName
"0.0.1"
versionName
"0.0.1"
...
@@ -72,7 +72,7 @@ android {
...
@@ -72,7 +72,7 @@ android {
vportal
{
vportal
{
applicationId
"com.vsoft.vera.vportal"
applicationId
"com.vsoft.vera.vportal"
versionCode
1
versionCode
1
versionName
"
1.1.0
"
versionName
"
0.2.1
"
}
}
}
}
}
}
...
...
app/src/main/AndroidManifest.xml
View file @
aa91bb6f
...
@@ -88,7 +88,8 @@
...
@@ -88,7 +88,8 @@
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.InAppWebViewActivity"
/>
<activity
android:name=
".ui.InAppWebViewActivity"
/>
<service
android:name=
".service.SyncService"
/>
<service
android:name=
".service.SyncService"
android:permission=
"android.permission.BIND_JOB_SERVICE"
/>
<provider
<provider
android:name=
"android.support.v4.content.FileProvider"
android:name=
"android.support.v4.content.FileProvider"
...
...
app/src/main/java/com/vsoft/vera/CatalogueApplication.java
View file @
aa91bb6f
package
com
.
vsoft
.
vera
;
package
com
.
vsoft
.
vera
;
import
android.app.job.JobInfo
;
import
android.app.job.JobScheduler
;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.IntentFilter
;
...
@@ -45,10 +48,11 @@ public class CatalogueApplication extends MultiDexApplication {
...
@@ -45,10 +48,11 @@ public class CatalogueApplication extends MultiDexApplication {
String
action
=
intent
.
getStringExtra
(
Constants
.
APPLICATION_BROADCAST_DATA_ACTION
);
String
action
=
intent
.
getStringExtra
(
Constants
.
APPLICATION_BROADCAST_DATA_ACTION
);
Log
.
d
(
Constants
.
TAG
,
"CatalogueApplication: onReceive: action: "
+
action
);
Log
.
d
(
Constants
.
TAG
,
"CatalogueApplication: onReceive: action: "
+
action
);
if
(
Constants
.
ACTION_SYNC
.
equals
(
action
))
{
if
(
Constants
.
ACTION_SYNC
.
equals
(
action
))
{
Intent
syncMatchSummaryIntentIntent
=
new
Intent
(
context
,
SyncService
.
class
);
//
Intent syncMatchSummaryIntentIntent = new Intent(context, SyncService.class);
if
(
Constants
.
DEBUG
)
if
(
Constants
.
DEBUG
)
Log
.
d
(
Constants
.
TAG
,
"CatalogueApplication: Start SyncService"
);
Log
.
d
(
Constants
.
TAG
,
"CatalogueApplication: Start SyncService"
);
context
.
startService
(
syncMatchSummaryIntentIntent
);
//context.startService(syncMatchSummaryIntentIntent);
scheduleJob
(
context
);
}
}
}
}
};
};
...
@@ -75,6 +79,20 @@ public class CatalogueApplication extends MultiDexApplication {
...
@@ -75,6 +79,20 @@ public class CatalogueApplication extends MultiDexApplication {
}
}
};
};
// schedule the start of the service every 10 - 30 seconds
public
static
void
scheduleJob
(
Context
context
)
{
ComponentName
serviceComponent
=
new
ComponentName
(
context
,
SyncService
.
class
);
JobInfo
.
Builder
builder
=
new
JobInfo
.
Builder
(
0
,
serviceComponent
);
builder
.
setMinimumLatency
(
1
*
1000
);
// wait at least
builder
.
setOverrideDeadline
(
3
*
1000
);
// maximum delay
//builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED); // require unmetered network
//builder.setRequiresDeviceIdle(true); // device should be idle
//builder.setRequiresCharging(false); // we don't care if the device is charging or not
JobScheduler
jobScheduler
=
context
.
getSystemService
(
JobScheduler
.
class
);
jobScheduler
.
schedule
(
builder
.
build
());
}
@Override
@Override
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
...
...
app/src/main/java/com/vsoft/vera/service/SyncService.java
View file @
aa91bb6f
package
com
.
vsoft
.
vera
.
service
;
package
com
.
vsoft
.
vera
.
service
;
import
android.app.IntentService
;
import
android.app.IntentService
;
import
android.app.job.JobParameters
;
import
android.app.job.JobService
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.os.AsyncTask
;
import
com.vsoft.vera.CatalogueApplication
;
import
com.vsoft.vera.CatalogueApplication
;
import
com.vsoft.vera.api.listeners.get.GetChatServerApiListener
;
import
com.vsoft.vera.api.listeners.get.GetChatServerApiListener
;
...
@@ -62,29 +65,45 @@ import static com.vsoft.vera.db.managers.CatalogueItemInputManager.getDirtyItemI
...
@@ -62,29 +65,45 @@ import static com.vsoft.vera.db.managers.CatalogueItemInputManager.getDirtyItemI
*/
*/
public
class
SyncService
extends
Intent
Service
{
public
class
SyncService
extends
Job
Service
{
private
SyncStatus
syncStatus
=
SyncStatus
.
FAIL
;
private
SyncStatus
syncStatus
=
SyncStatus
.
FAIL
;
public
SyncService
()
{
@Override
super
(
SyncService
.
class
.
getSimpleName
());
public
boolean
onStartJob
(
JobParameters
params
)
{
BackgroundQueueAsync
backgroundQueueAsync
=
new
BackgroundQueueAsync
();
backgroundQueueAsync
.
execute
();
return
false
;
}
}
@Override
@Override
p
rotected
void
onHandleIntent
(
Intent
intent
)
{
p
ublic
boolean
onStopJob
(
JobParameters
params
)
{
CatalogueApplication
application
=
(
CatalogueApplication
)
getApplication
()
;
return
false
;
if
(!
application
.
isNetConnected
())
{
}
CatalogueLog
.
e
(
"SyncService: onHandleIntent(): Not connected to net. Exit."
);
public
class
BackgroundQueueAsync
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
return
;
public
BackgroundQueueAsync
()
{
}
}
if
(
Util
.
isChatItemEnabled
())
{
@Override
if
(
application
.
getSocket
()
==
null
)
{
protected
Void
doInBackground
(
Void
...
voids
)
{
getChatServerUrl
();
CatalogueApplication
application
=
(
CatalogueApplication
)
getApplication
();
if
(!
application
.
isNetConnected
())
{
CatalogueLog
.
e
(
"SyncService: onHandleIntent(): Not connected to net. Exit."
);
}
else
{
if
(
Util
.
isChatItemEnabled
())
{
if
(
application
.
getSocket
()
==
null
)
{
getChatServerUrl
();
}
}
startSync
();
}
}
}
startSync
();
return
null
;
}
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment