- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
目前我的问题是,每当我尝试访问通过 DataItem 层发送的 ArrayList<> 时,它都会告诉我该对象为空。
有人可以阐明问题出在哪里吗?
移动
public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
--variables
@Override
protected void onCreate(Bundle savedInstanceState) {
if(!PreferenceManager.getDefaultSharedPreferences(this)
.getStringSet("wristaroo", new HashSet<String>()).isEmpty()) {
tasksSet = PreferenceManager.getDefaultSharedPreferences(this)
.getStringSet("wristaroo", new HashSet<String>());
actsList = new ArrayList<>(tasksSet);
}
-----
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wearable.API)
.build();
googleApiClient.connect();
super.onCreate(savedInstanceState);
-----
Button btnSave = (Button) findViewById(R.id.sendButton);
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PutDataMapRequest dataMap = PutDataMapRequest.create("/wristaroo/customschedule");
dataMap.getDataMap().putStringArrayList("schedule", actsList);
PutDataRequest request = dataMap.asPutDataRequest();
PendingResult<DataApi.DataItemResult> result = Wearable.DataApi
.putDataItem((googleApiClient), request);
System.out.println("Request: " + request);
System.out.println("Result: " + result);
}
});
}
-----
@Override
public void onConnected(Bundle bundle) {
new DataTask (this, actsList).execute();
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
class DataTask extends AsyncTask<Node, Void, Void> {
private ArrayList<String> contents;
Context c;
public DataTask ( Context c, ArrayList<String> contents) {
this.c = c;
this.contents = contents;
}
@Override
protected Void doInBackground(Node... nodes) {
PutDataMapRequest dataMap = PutDataMapRequest.create("/wristaroo/customschedule").setUrgent();
dataMap.getDataMap().putStringArrayList("schedule", actsList);
PutDataRequest request = dataMap.asPutDataRequest().setUrgent();
Log.i("Data", "data");
DataApi.DataItemResult dataItemResult = Wearable.DataApi
.putDataItem((googleApiClient), request).await();
System.out.println("dataItemResult: " + dataItemResult);
return null;
}
}
}
磨损
public class MainActivity extends Activity implements DataApi.DataListener,GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
super.onCreate(savedInstanceState);
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wearable.API)
.build();
---------
@Override
public void onConnected(Bundle bundle) {
Wearable.DataApi.addListener(googleApiClient, this).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
Log.i("myTag", String.valueOf(status));
}
});
System.out.println("onConnected Activated!!!");
}
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// DataItem changed
DataItem item = event.getDataItem();
if (item.getUri().getPath().compareTo("/wristaroo/customschedule") == 0) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
data = dataMap.getStringArrayList("schedule");
}
} else if (event.getType() == DataEvent.TYPE_DELETED) {
// DataItem deleted
}
}
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult)
list 移动
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.michaeldvinci.conedmiro.schedaroo">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".EditActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".AddActivity"
android:label="@string/app_name">
</activity>
</application>
</manifest>
明显磨损
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.michaeldvinci.conedmiro.schedaroo">
<uses-feature android:name="android.hardware.type.watch" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
<activity
android:name=".MainActivity"
android: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=".byDayActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".byChoiceActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".byStageActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".byTimeActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".byStageActActivity"
android:label="@string/app_name">
</activity>
</application>
</manifest>
按下移动应用上的[发送]按钮时的输出
03-29 18:33:47.948 5246-5246/com.michaeldvinci.conedmiro.schedaroo W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=1307.8564, y[0]=2230.7813, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=473778, downTime=468682, deviceId=0, source=0x1002 }
03-29 18:33:47.948 5246-5246/com.michaeldvinci.conedmiro.schedaroo W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=1307.8564, y[0]=2230.7813, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=473778, downTime=468682, deviceId=0, source=0x1002 }
03-29 18:33:47.948 5246-5246/com.michaeldvinci.conedmiro.schedaroo W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=1307.8564, y[0]=2230.7813, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=473778, downTime=468682, deviceId=0, source=0x1002 }
03-29 18:33:47.948 5246-5246/com.michaeldvinci.conedmiro.schedaroo W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=1307.8564, y[0]=2230.7813, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=473778, downTime=468682, deviceId=0, source=0x1002 }
03-29 18:33:48.179 5246-5246/com.michaeldvinci.conedmiro.schedaroo I/System.out: Request: PutDataRequest[dataSz=108, numAssets=0, uri=wear:/wristaroo/customschedule, syncDeadline=0]
03-29 18:33:48.179 5246-5246/com.michaeldvinci.conedmiro.schedaroo I/System.out: Result: com.google.android.gms.wearable.internal.zzx$1@1ded1a8
最佳答案
这可能最终是一个不正确的答案,但我认为 setUrgent()
标志可能很重要:
请使用此代码:
PutDataMapRequest dataMap = PutDataMapRequest.create("/wristaroo/customschedule");
dataMap.getDataMap().putStringArrayList("schedule", actsList);
PutDataRequest request = dataMap.asPutDataRequest();
request.setUrgent();
Log.i("Data", "data");
DataApi.DataItemResult dataItemResult = Wearable.DataApi
.putDataItem((googleApiClient), request).await();
关于java - 从手机发送ArrayList<> DataItem到穿戴设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36254079/
在德国,移动运营商通常会提供一种简单的方法来配置您的手机的 MMS 和 GPRS:在运营商的网站上输入您的电话号码和设备型号后,您会收到一条发送给您的“配置短信”。 我试图从技术角度理解它是如何工作的
我正在开发一个非常复杂的应用程序。它针对手机和平板电脑有不同的布局,我不知道最好的方法。 我听说您可以发布两个不同的应用程序,一个用于移动设备,另一个用于平板电脑,但人们不推荐它。 我应该用两个不同的
我不确定这个问题属于这里....但仍然.... 我的应用程序每 3 分钟与服务器交换一次数据。我在手机覆盖范围内使用蜂窝平板电脑(不是 Wi-Fi)。如果一个人在没有手机覆盖的地方使用它,他将不会获得
我有这样的 CSS: .editTable-body { width: 100%; height:140px; margin-top: 20px; overflow:
我有这个链接,它在移动设备上被设计为按钮,我面临的问题是它在手机和平板电脑上看起来不同。这是因为设备分辨率还是我应该通过 CSS 修复的问题。这是我当前的 CSS CSS border-radiu
大家好,我一个月前开始学习网络开发,但我遇到了背景图片无法在移动设备上正确显示的问题。 我正在使用下面的模板,甚至这个模板也有同样的问题。 问题只是背景图像在移动设备上放大,而不是相应地与屏幕尺寸成比
我一直在尝试为我的网站制作一个导航栏,但是当我移动它时,我导航栏中的列表移动了 40 像素到计算机屏幕的右侧,那里没有任何东西。 你能帮帮我吗? 最佳答案 在您的导航栏样式中,将导航栏的宽度设置为 1
一周以来,我一直不明白为什么我的网站被设计成响应式的,一切正常吗?笔记本电脑即使放在小尺寸的情况下也能完美运行,然后进入我的手机却没有响应。 我试过卸载插件,我更改了主题,但找不到原因。 你能抱住我吗
我在 my website 上实现了以下字体. /* Vivaldi Font */ @font-face { font-family: 'vivaldi'; src: url('as
我正在使用 Angular 4 并构建一个应用程序。它工作正常,但当我在移动设备上运行时出现问题。整个风格发生了变化并分发了整个应用程序。我担心我必须做什么。任何帮助将不胜感激 最佳答案 在表格前取
我目前使用的是 HTC Wildfire 手机的接近传感器。问题在于,如果传感器前方 1 厘米范围内有物体,它只会返回一个 bool 值。 所以,我想问一下市场上是否有一款 Android 手机具有接
根据 this Android C2DM 通过心跳机制使套接字保持 Activity 状态,使其能够接收推送消息。这让我希望我可以通过活跃的 wifi 连接向休眠手机发送消息。 我已经将“delay_
我不希望小型设备的边缘有任何空白。当屏幕已经很小时,使用除屏幕全宽之外的任何东西都会适得其反。 所以我通过wordpress使用了一个主题,但我想出了容器div并且能够修改它,我想让它更窄。 我还声明
有谁知道这些设备之一是否连接到网络,是否可以从 header 或其他方式读取其电话号码? 最佳答案 电话号码不会出现在 HTTP header 中。您的 IP 地址将对网络服务器可见,仅此而已。 编辑
我在使用以下步骤在 android 设备上设置设备所有者时遇到错误。这过去在其他设备上也有效: 执行恢复出厂设置 在设备上启用 Debug模式 从命令行在连接的设备上运行以下命令: adb insta
有人尝试在 Windows Phone 7.1 (RC) 上使用 Udp 单播吗?我有几个问题想问你们。 根据文件http://msdn.microsoft.com/en-us/library/sys
我正在制作一个游戏(仅使用 eclipse 和 android sdk),并且我有一个基于文本文件输入的关卡构建功能。 例如,“levelone.txt”可能包含“[2,5],[14,7],[10,9
我听说要测试 Android 应用程序,您必须在 2 部不同的手机上进行测试(取决于分辨率)推荐哪些手机? 最佳答案 我还建议在一台配备“纯”Android 的设备上进行测试,并且至少在另一台配备 H
我正在使用蓝牙设备手动连接 Android 手机,没有问题。但我的问题是当我启动 Activity 或应用程序时如何自动连接。 我正在引用示例 API 中的蓝牙聊天进行连接。 http://devel
我知道我可以使用 uri 在页面之间传递值,例如: NavigationService.Navigate( new Uri("/DestinationPage.xaml?parameter1=v1",
我是一名优秀的程序员,十分优秀!