我正在尝试允许注册URI以使用我的应用程序打开.就像PatternRepository黑莓和iPhone上的CFBundleURLName/一样CFBundleURLSchemes.如何在Android上获得相同的结果?
系统将发送带有以下链接的电子邮件: myapp://myapp.mycompany.com/index/customerId/12345.这个想法是用户应该能够点击链接以打开应用程序中的客户活动.
我已尝试过其他SO帖子的大量建议,但我无法让操作系统识别模式并打开我的应用程序.
在Gmail应用中,它看起来像这样:myapp:// myapp.mycompany.com/index/customerId/12345.它识别并强调myapp.mycompany.com/index/customerId/12345链接的一部分,并在浏览器中打开它.该myapp://部分未链接.
标准邮件应用程序将整个链接视为纯文本.
我在这里错过了什么?
PS:我已经看过 如何在Android上实现我自己的URI方案 以及如何通过在Android OS中的浏览器中调用URL来注册一些URL命名空间(myapp://app.start/)来访问您的程序?
清单:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="2"
android:versionName="0.0.8"
package="com.mycompany.myapp.client.android">
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="7"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:label="@string/app_name"
android:name="myappApplication"
android:icon="@drawable/ic_icon_myapp"
android:debuggable="true">
<activity
android:label="My App"
android:name=".gui.activity.LoginActivity"
label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".gui.activity.CustomerDetailActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp"/>
</intent-filter>
</activity>
<activity android:name=".gui.activity.CustomerDetailActivity"/> …Run Code Online (Sandbox Code Playgroud) 我需要在Android 2.3设备上设置应用内OBEX服务器.使用蓝牙聊天示例代码,我能够设置OBEX服务器.但是,服务器需要使用自定义UUID,因此该服务未注册为"OBEX服务器"
# sdptool browse local
...(snip)...
Service Name: OBEX Object Push
Service RecHandle: 0x10000
Service Class ID List:
UUID 128: ab123abc-1a2b-3c4d-5d7f-1234567890ab
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 18
Run Code Online (Sandbox Code Playgroud)
因此,当我收到数据时,看起来我收到的是原始OBEX连接请求:
80 00 07 10 00 04 00 00 00 00 ...(snip)... 00 00 00 (1kb file)
Run Code Online (Sandbox Code Playgroud)
是否有我可以使用的OBEX实现,或者我是否必须自己实现协议?
我不想使用内置的OBEX服务器 - 这必须在应用程序中.我尝试过BlueCove,但是在注册服务时遇到问题我放弃了它.
当我尝试findViewById()使用我的自定义视图时,我会继续获取ClassCastException.我已经尝试了很多东西,我确信我现在已经破坏了代码!
为了确保我不会疯狂,我将课程简化为最低限度,以便找出问题所在.
我是android编程的新手,我确信我缺少一些基本的东西.
这是BaseImageView一个扩展视图类.
package com.company.product.client.android.gui.views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.View;
public class BaseImageView
extends View
{
public BaseImageView(Context context)
{
super(context);
}
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
canvas.drawColor(Color.GREEN);
}
}
Run Code Online (Sandbox Code Playgroud)
这是班级LiveImageView的延伸BaseImageView.
package com.company.product.client.android.gui.views;
import android.content.Context;
import android.util.AttributeSet;
public class LiveImageView
extends BaseImageView
{
public LiveImageView(Context context, AttributeSet attrs)
{
super(context);
}
}
Run Code Online (Sandbox Code Playgroud)
这是布局my_view.xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<View
class="com.company.product.client.android.gui.views.LiveImageView"
android:id="@+id/lvImage" …Run Code Online (Sandbox Code Playgroud)