I have this html:

我有这个HTML:

<p>
    <a href="http://en.wikipedia.org/wiki/Sauropelta">sawr-o-pel-te</a> meaning 'lizard shield'
</p>
<p>
    April 7th, 2015
</p>
<p>
    4/7/2015
</p>
<p>
    April 7th
</p>
<p>
    Next Monday 6th<br>
</p>
<p>
    202 E South St<br>
    Orlando, FL 32801
</p>
<h3>Quick Facts</h3>
<ul>
    <li>One of the most well-understood nodosaurids<span></span></li>
    <li>The earliest known genus of nodosaurid<span></span></li>
    <li>Measured about 5 meters (16.5 ft) long<span></span></li>
    <li>The tail made up nearly half of its body length</li>
</ul>
<span></span>

And I want to know if its possible to automatically hyperlink the dates so when the user presses on them you can add them to the users(phone's) calendar? A good example of how this should work is Gmail. When there is a date or the word(tomorrow, this friday, etc..) it should be automatically linked so the date can be added to calendar.

我想知道是否可以自动超链接日期,以便当用户按下它们时,您可以将它们添加到用户(手机的)日历中?这应该如何运作的一个很好的例子是Gmail。如果有日期或单词(明天,本周五等),则应自动链接,以便将日期添加到日历中。

Update:

更新:

Does any one know if there is a ex. javascript that I can add to the app that will do this job for me?

有没有人知道是否有前任。我可以添加到应用程序的JavaScript,这将为我做这个工作?

2 个解决方案

#1


5

Yes, it is possible.

对的,这是可能的。

Use the WebViewClient method shouldOverrideUrlLoading to intercept any links containing a certain value. Let's say you create a link like this:

使用WebViewClient方法shouldOverrideUrlLoading来拦截包含特定值的任何链接。假设您创建了这样的链接:

<a href="#addtocalendar"> April 7th, 2015 - Add to Calendar</a>

Now, we'll use the shouldOverrideUrlLoading to intercept the tap and add the event to calendar, i.e.:

现在,我们将使用shouldOverrideUrlLoading拦截tap并将事件添加到日历中,即:

    mWebView.setWebViewClient(new WebViewClient(){
        public boolean shouldOverrideUrlLoading(WebView wView, String url)
        {
            if (url.contains("addtocalendar") ) {
               Calendar cal = Calendar.getInstance();              
               Intent intent = new Intent(Intent.ACTION_EDIT);
               intent.setType("vnd.android.cursor.item/event");
               intent.putExtra("allDay", false);
               intent.putExtra("rrule", "FREQ=YEARLY"); //optional recurring event
               intent.putExtra("beginTime", cal.getTimeInMillis());
               intent.putExtra("endTime", cal.getTimeInMillis()+3600000); // adds 1 hour
               intent.putExtra("title", "Event on April 7th, 2015");
               startActivity(intent);

               return true;
           }
      }
});

Add the following permissions to AndroidManifest.xml

将以下权限添加到AndroidManifest.xml

<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />

shouldOverrideUrlLoading

shouldOverrideUrlLoading

boolean     shouldOverrideUrlLoading(WebView view, String url)

Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView.

当要在当前WebView中加载新URL时,为主机应用程序提供接管控件的机会。

http://developer.android.com/reference/android/webkit/WebViewClient.html

http://developer.android.com/reference/android/webkit/WebViewClient.html


Android Calendar Provider

Android日历提供商

http://developer.android.com/guide/topics/providers/calendar-provider.html

http://developer.android.com/guide/topics/providers/calendar-provider.html

更多相关文章

  1. 函数的作用是:在javascript中将时间戳转换为人工日期
  2. 从服务器(任何服务器)获取当前日期和时间。仅限javascript
  3. 输入类型=日期的日期显示为dd-mm-yyyy格式
  4. 我可以使用onBlur事件对TextBox进行日期检查吗?
  5. Day.js :一个轻量的处理时间和日期的 JavaScript 库
  6. 使用Isotop过滤日期
  7. 如何使用Require JS配置具有第三方js依赖项的日期选择器?
  8. 第三节(JavaScript 对象、日期,函数)
  9. jquery.fullCalendar官方文档翻译(一款小巧好用的日程管理日历,

随机推荐

  1. android快捷键
  2. Android设置权限问题
  3. Android有两种方法检测USB设备插入
  4. Android学习笔记1
  5. android实现点击按钮控制图片切换
  6. 我的第一个Android 多媒体的Demo
  7. Android请求获取Java后端数据,登录界面例
  8. Android(安卓)Gesture手势操作(手势翻页
  9. 百度地图开发Marker|Polyline隐藏或显示
  10. 从Android读取Unity assets下的图片并保