- 전체
- android studio
- Android SDK
- Android NDK
- Android ADK
- Android Etc. Lib.
- Android dalvik VM
- Android 보안
- PhoneGap
- AOSP 개발
- MIT App Inventor 2
- kivy (python)
- ionic framework
- Kotlin (코틀린)
- React Native
Android SDK [Android SDK] Making Android WebView autorefresh periodically
2024.05.01 17:02
[Android SDK] Making Android WebView autorefresh periodically
I'm trying to create a hybrid application in Android that has a web view that's supposed to refresh every five minutes or so, or a few seconds after the user has done a change in the service. Most solutions that I've tried can be summarized into this SO question's answer. The problem is that everytime the application tries to refresh the web view through that, the software crashes because "an UI element has been called from non-UI thread".
Is there another alternative? I think I can do a periodical refresh through Javascript in the web page itself, but considering that our application has been designed to run even if there's no network and we can't then refresh it when user changes the status of the native side, it's not optimal. Does anyone have any suggestions?
Thanks in advance
---- Answer ----
Using a Toast as an example as how you can keep calling it. You can call the reload(); after a user changes information rather than the onCreate.
Load in the oncreate
Toast.makeText(LogThirdPager.this, "Hello", Toast.LENGTH_SHORT).show();
// mWebview.loadUrl("http://www.google.com");
reload();
Then call this after it. It will continue to reload the page every 5 seconds for example.
public void reload() {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
// Do something after 5s = 5000ms
Toast.makeText(LogThirdPager.this, "Hello", Toast.LENGTH_SHORT).show();
reload();
// mWebview.loadUrl("http://www.google.com");
}
}, 5000);
}
[출처] https://stackoverflow.com/questions/28255214/making-android-webview-autorefresh-periodically
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 12 |
App Inventor - MySQL interface 앱 인벤터 mysql 연결
| 졸리운_곰 | 2018.04.07 | 8002 |
| 11 |
Connect App Inventor to MySQL Database 앱 인벤터와 mysql 데이터베이스 연결
| 졸리운_곰 | 2018.04.07 | 7273 |
| 10 |
Create an API (PHP) 앱 인벤터와 php 통합
| 졸리운_곰 | 2018.04.07 | 630 |
| 9 |
Using the WebViewer Control in App Inventor 앱인터에서 웹뷰 컨트롤 사용
| 졸리운_곰 | 2018.03.24 | 512 |
| 8 |
WebView Javascript Processor for App Inventor 앱 인벤터 웹뷰 자바스크립트 인터페이스
| 졸리운_곰 | 2018.03.24 | 505 |
| 7 |
Creating a digital wallet application in App Inventor 2
| 졸리운_곰 | 2017.05.01 | 287 |
| 6 | Creating a Custom TinyWebDB Service | 졸리운_곰 | 2016.05.18 | 201 |
| 5 |
TinyDB is a lightweight document oriented database
| 졸리운_곰 | 2016.05.16 | 270 |
| 4 |
구글 앱엔진에 의한 소형웹데이터베이스의 접속방법 tinywebdb
| 졸리운_곰 | 2016.05.15 | 547 |
| 3 |
App inventor 멀티스크린, 스크린 이동, 다중화면,
| 졸리운_곰 | 2016.02.17 | 779 |
| 2 |
Communicating with Web APIs
| 졸리운_곰 | 2016.02.17 | 1080 |
| 1 |
JSON data on the Android mobile with App Inventor 2
| 졸리운_곰 | 2016.02.17 | 364 |

