Java 在后台继续工作的全屏应用程序
我已经为smartwatch制作了一个Android应用程序,以便全屏显示HTML5网页,其中包含一个实时时钟和一个带有进度条的事件,该事件仍将运行多长时间(HTML5页面可在www.janvangalen.nl上查看)。 但是smartwatch会退回到睡眠模式(这是有意的),但我无法让应用程序在后台继续运行。振动(通知新活动)不起作用,激活手表显示时钟仍在运行,但该活动仍然是进入睡眠时的活动 我在Android Studio中开发,以下文件是我应用程序的基础 AndroidManifest.xmlJava 在后台继续工作的全屏应用程序,java,android,html,background,fullscreen,Java,Android,Html,Background,Fullscreen,我已经为smartwatch制作了一个Android应用程序,以便全屏显示HTML5网页,其中包含一个实时时钟和一个带有进度条的事件,该事件仍将运行多长时间(HTML5页面可在www.janvangalen.nl上查看)。 但是smartwatch会退回到睡眠模式(这是有意的),但我无法让应用程序在后台继续运行。振动(通知新活动)不起作用,激活手表显示时钟仍在运行,但该活动仍然是进入睡眠时的活动 我在Android Studio中开发,以下文件是我应用程序的基础 AndroidManifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nl.janvangalen.www.imagewatch">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
tools:context=".FullscreenActivity">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<!-- This FrameLayout insets its children based on system windows using
android:fitsSystemWindows. -->
<WebView
android:id="@+id/activity_fullscreen_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
我还找到了如何让应用程序在后台工作的方法,并创建了一个新的.java(fort第二个公共类)。但是,在下面的代码中,我不知道要输入什么才能使它工作
package nl.janvangalen.www.smartwatch;
import android.app.IntentService;
import android.content.Intent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import nl.janvangalen.www.imagewatch.R;
public class RSSPullService extends IntentService {
@Override
protected void onHandleIntent(Intent workIntent) {
// Gets data from the incoming Intent
String dataString = workIntent.getDataString();
// ...
// Do work here, based on the contents of dataString
}
}
由于工作已经在全屏脚本中完成,因此需要在那里完成哪些工作
有人能帮我吗?解决了。用前景代替背景
package nl.janvangalen.www.smartwatch;
import android.app.IntentService;
import android.content.Intent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import nl.janvangalen.www.imagewatch.R;
public class RSSPullService extends IntentService {
@Override
protected void onHandleIntent(Intent workIntent) {
// Gets data from the incoming Intent
String dataString = workIntent.getDataString();
// ...
// Do work here, based on the contents of dataString
}
}