小编Ste*_*ven的帖子

什么是Android WebViewClient中的onPageFinished?

我正在尝试在我的网页加载完成后在Android WebView上执行操作.我设置我的WebView以使用WebViewClient来使用onPageFinished事件回调.但是,经过一些测试后,似乎还没等到页面上的所有JS都在我的onPageFinished代码触发之前完成加载.

Google文档说明了这一点:

public void onPageFinished (WebView view, String url)
Run Code Online (Sandbox Code Playgroud)

在API级别1中添加通知主机应用程序页面已完成加载.仅对主框架调用此方法.调用onPageFinished()时,渲染图片可能尚未更新.要获取新图片的通知,请使用onNewPicture(WebView,Picture).

参数

view正在启动回调的WebView.

url页面的网址.

1)onPageFinished只等待DOM加载吗?

2)有没有办法检测页面上的任何JS何时完成?如果是这样,我应该使用什么?

我没有在WebViewClient中看到任何可能用于此目的的内容.我不想添加延迟,因为我的用户可以在EDGE或LTE上.

android webview webviewclient

17
推荐指数
1
解决办法
8774
查看次数

android:backgroundDimAmount的值是什么意思?

android:backgroundDimAmount的文档说:

"public static final int backgroundDimAmount

弹出菜单,对话框或类似内容时的默认背景暗淡量.必须是浮点值,例如"1.2".

这也可以是对资源的引用(其形式为"@〔包:]类型:名称为")("?[包:] [类型:]名称"的形式)或主题属性包含该类型的值.

常数值:16842802(0x01010032)"

什么是这个浮动,1.2,实际上是什么意思?什么数字表示100%淡出(我可以使用的浮点数是多少?)?

android android-xml android-theme

13
推荐指数
1
解决办法
4270
查看次数

将一个整数数组从AppWidget传递给一个由RemoteViewsFactory呈现的预先存在的RemoteViewsService

我有一个包含StackView的AppWidget.与AppWidget一起,我有一个服务,当用户将我的AppWidget添加到他们的主屏幕时每两小时轮询一次新数据时启动该服务.当服务找到新数据时,我需要它提醒我的AppWidget,并将该数据传递给RemoteViewsService(具有我的RemoteViewsFactory),以便它可以为新数据创建必要的视图.

目前,当服务找到新数据时,我向AppWidget广播已发现新数据,将该数据作为意图内的整数数组传递.

我的AppWidgetProvider中的onReceive方法将该数据拉出来,然后我将完成设置一个新的intent的过程,该intent将传递给我的RemoteViews for AppWidget.示例代码如下:

public void onReceive( Context context, Intent intent )
{
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds( new ComponentName( context,  SampleAppWidgetProvider.class ) );

    int[] sampleData = intent.getIntArrayExtra( Intent.EXTRA_TITLE );
    for ( int i = 0; i < appWidgetIds.length; i++ )
    {
        // RemoteViewsFactory service intent
        Intent remoteViewsFactoryIntent = new Intent( context, SampleAppWidgetService.class );
        remoteViewsFactoryIntent.putExtra( AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i] );
        remoteViewsFactoryIntent.setData( Uri.parse( remoteViewsFactoryIntent.toUri( Intent.URI_INTENT_SCHEME ) ) );
        remoteViewsFactoryIntent.putExtra( Intent.EXTRA_TITLE, sampleData );

        RemoteViews rv = new RemoteViews( context.getPackageName(), R.layout.widget_layout );

        // Sync up …
Run Code Online (Sandbox Code Playgroud)

android android-widget android-service stackview android-appwidget

6
推荐指数
1
解决办法
2855
查看次数