Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
23854c17
Commit
23854c17
authored
Sep 30, 2021
by
Kim Jinsung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #43772【@Form】Android端末でのIO帳票出力表示について
parent
6555a586
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
1 deletions
+48
-1
ABVJE_UI_Android/src/jp/agentec/abook/abv/launcher/android/OnAppDownloadReceiver.java
+48
-1
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/launcher/android/OnAppDownloadReceiver.java
View file @
23854c17
...
...
@@ -9,10 +9,16 @@ import android.app.DownloadManager;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.support.v4.content.FileProvider
;
import
android.util.Log
;
import
android.widget.Toast
;
import
static
android
.
content
.
ContentValues
.
TAG
;
/**
* 新しいAPKのダウンロードが完了したときの通知を受け取る
* @author jang
...
...
@@ -22,26 +28,67 @@ public class OnAppDownloadReceiver extends BroadcastReceiver {
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
intent
.
getAction
().
equals
(
DownloadManager
.
ACTION_DOWNLOAD_COMPLETE
))
{
if
(
DownloadManager
.
ACTION_DOWNLOAD_COMPLETE
.
equals
(
intent
.
getAction
()))
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
return
;
}
long
id
=
intent
.
getLongExtra
(
DownloadManager
.
EXTRA_DOWNLOAD_ID
,
-
1
);
Logger
.
d
(
"Download Complete ID : "
+
id
);
String
downloadedTo
=
null
;
DownloadManager
dm
=
(
DownloadManager
)
context
.
getSystemService
(
context
.
DOWNLOAD_SERVICE
);
final
Cursor
cursor
;
if
(
dm
!=
null
)
{
// 現在ダウンロードされたファイルを確認する。
cursor
=
dm
.
query
(
new
DownloadManager
.
Query
().
setFilterById
(
id
));
if
(
cursor
.
moveToFirst
())
{
downloadedTo
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
DownloadManager
.
COLUMN_LOCAL_URI
));
Log
.
d
(
TAG
,
"The file has been downloaded to: "
+
downloadedTo
);
if
(
downloadedTo
!=
null
&&
!
downloadedTo
.
endsWith
(
".apk"
))
{
Toast
.
makeText
(
context
,
context
.
getResources
().
getString
(
R
.
string
.
download_success
),
//To notify the Client that the file is being downloaded
Toast
.
LENGTH_LONG
).
show
();
return
;
}
}
}
if
(
id
==
-
1
)
{
// ダウンロードマネージャの通知領域をクリックした場合はメッセージ表示のみ
Toast
.
makeText
(
context
,
intent
.
getAction
(),
Toast
.
LENGTH_LONG
).
show
();
}
else
{
// APKファイルの場合
if
(
downloadedTo
!=
null
&&
downloadedTo
.
toLowerCase
().
endsWith
(
".apk"
))
{
File
file
=
new
File
(
context
.
getExternalFilesDir
(
Environment
.
DIRECTORY_DOWNLOADS
),
ABVEnvironment
.
APK_FILE_NAME
);
if
(
file
.
exists
())
{
try
{
// Android7でアップデート
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
Uri
apkUri
=
FileProvider
.
getUriForFile
(
context
,
context
.
getPackageName
()
+
".provider"
,
file
);
Intent
updateIntent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
updateIntent
.
setDataAndType
(
apkUri
,
"application/vnd.android.package-archive"
);
updateIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
updateIntent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
context
.
startActivity
(
updateIntent
);
}
else
{
Intent
i
=
new
Intent
(
Intent
.
ACTION_VIEW
);
// Activity以外からActivityを呼び出すためのフラグを設定
i
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
i
.
setDataAndType
(
Uri
.
fromFile
(
file
),
"application/vnd.android.package-archive"
);
context
.
startActivity
(
i
);
}
}
catch
(
Exception
ex
)
{
Logger
.
e
(
"OnAppDownloadReceiver.startActivity(fileIntent)."
,
ex
);
}
}
else
{
Toast
.
makeText
(
context
,
"No Exist APK File: "
,
Toast
.
LENGTH_LONG
).
show
();
}
}
}
}
}
}
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