拜托,如果我犯错误,你能告诉我吗?
NSString *sharedMsg=[NSString stringWithFormat:@"Hello world"];
UIImage* sharedImg=[UIImage imageNamed:@"image"];
NSArray* sharedObjects=[NSArray arrayWithObjects:sharedMsg, sharedImg, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc]
initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
在运行时,当我选择Facebook的图标时,文本丢失,图像被正确显示.
我的xcode是6.3.1,在iPad上测试过.
这是我的解决方案
动画/ pulse.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="300"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:toXScale="0.75"
android:toYScale="0.75"
android:interpolator="@android:interpolator/bounce" />
<scale
android:duration="100"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:toXScale="1.25"
android:toYScale="1.25"
android:interpolator="@android:interpolator/bounce" />
</set>
Run Code Online (Sandbox Code Playgroud)
然后在activity.java中:
ImageView imageView = (ImageView) findViewById(R.id.image);
imageView.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulse));
Run Code Online (Sandbox Code Playgroud)
我不满意,因为真正的跳动的心脏有更优雅的收缩.怎么可以改进?
编辑:我认为一个很好的效果会模仿心跳.快速收缩然后是另一个收缩.也许最后一局在上半场可能很快,然后在下半场慢慢逆转.有没有办法让所有这些效果相互引发?
我是这样做的:
context.getResources().getConfiguration().locale
Run Code Online (Sandbox Code Playgroud)
Configuration.locale 如果目标是24,则弃用.所以我做了这个改变:
context.getResources().getConfiguration().getLocales().get(0)
Run Code Online (Sandbox Code Playgroud)
现在它说它只有minSdkVersion24,所以我不能使用它因为我的最小目标较低.
什么是正确的方法?
我遵循此处描述的相同步骤 (Google Fit客户端连接部分工作正常).
final DataType dataType=TYPE_STEP_COUNT_DELTA;
DataSourcesRequest requestData = new DataSourcesRequest.Builder()
.setDataTypes(dataType) // At least one datatype must be specified.
.build();
Fitness.SensorsApi.findDataSources(mClient, requestData)
.setResultCallback(new ResultCallback<DataSourcesResult>() {
@Override
public void onResult(DataSourcesResult dataSourcesResult) {
Log.i(TAG, "Result: " + dataSourcesResult.getDataSources().size() + " sources "
+ dataSourcesResult.getStatus().toString());
for (DataSource dataSource : dataSourcesResult.getDataSources()) {
Log.i(TAG, "Data source found: " + dataSource.toString());
Log.i(TAG, "Data Source type: " + dataSource.getDataType().getName());
}
}
});
Run Code Online (Sandbox Code Playgroud)
当我要求数据源时,我只得到一个结果就是智能手机.如果我添加一个监听器,那么我真的得到数据,所以它正在工作.
不过它也可以通过手机与Android Wear智能手表Gear Live和Android Wear应用程序连接.Google Fit已安装在两者中,但我想从智能手表获取数据.
在我阅读的官方指南中
Sensors API提供对Android设备上可用传感器以及可穿戴设备等配套设备中可用传感器的原始传感器数据流的访问 . …
如果我更改了编辑器设置,我可以看到更多以黄色标记的警告,但我必须手动查找并查看它们.编译完成后我需要一个列表,所以我可以点击并检查每个列表.
Android studio是2.1.1
编辑:特别是我需要在app gradle脚本中看到与minSdk更改相关的所有警告
这是广告客户(通知data作为AdvertiseData类型传递)
private void advertise() {
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothLeAdvertiser advertiser = bluetoothAdapter.getBluetoothLeAdvertiser();
AdvertiseSettings settings = new AdvertiseSettings.Builder()
.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
.setConnectable(false)
.build();
ParcelUuid pUuid = new ParcelUuid(UUID.fromString("cf2c82b6-6a06-403d-b7e6-13934e602664"));
AdvertiseData data = new AdvertiseData.Builder()
//.setIncludeDeviceName(true)
.addServiceUuid(pUuid)
.addServiceData(pUuid, "123456".getBytes(Charset.forName("UTF-8")))
.build();
AdvertiseCallback advertiseCallback = new AdvertiseCallback() {
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
Log.i(tag, "Advertising onStartSuccess");
super.onStartSuccess(settingsInEffect);
}
@Override
public void onStartFailure(int errorCode) {
Log.e(tag, "Advertising onStartFailure: " + errorCode);
super.onStartFailure(errorCode);
}
};
advertiser.startAdvertising(settings, data, advertiseCallback);
}
Run Code Online (Sandbox Code Playgroud)
它成功地开始了.
这是扫描仪
private …Run Code Online (Sandbox Code Playgroud) <receiver
android:name="MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
我不明白是否需要通知.如果确实有任何应用程序可以通过这些操作调用我的接收器?所以,如果我把它弄错了,系统可以将动作发送给我的接收器吗?
从智能手机使用HistoryAPI如果我询问用户的历史记录和DataType.TYPE_HEART_RATE_BPM最后一个小时,从当前时间开始,我错过了过去半小时的数据.
如果我使用智能手表中的相同程序向Google Fit询问它们,那就没关系了.
所以这不是数据提取的问题,因为它取决于设备.
也许这是同步问题?如何以编程方式强制更新Google Fitness Store存储库中的记录?
这就是我所说的.
编辑:这是我建立请求的方式
DataReadRequest readRequest = new DataReadRequest.Builder()
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.enableServerQueries()
.read(dataType)
.build();
Run Code Online (Sandbox Code Playgroud) 我已经定义了两个具有不同主要,主要暗,主要光和强调颜色的主题.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
<style name="AppTheme2" parent="AppTheme">
<item name="colorPrimary">@color/primary_2</item>
<item name="colorPrimaryDark">@color/primary_dark_2</item>
<item name="colorAccent">@color/accent_2</item>
</style>
Run Code Online (Sandbox Code Playgroud)
AppTheme默认为<application/>
Then然后我在特定活动中设置AppTheme2.
在一个可绘制的文件xml中,我使用了colors.xml中定义的相同的AppTheme原色
drawable用于两个主题的许多活动,所以当有AppTheme2我看到不同的颜色.有没有办法让drawable使用当前主题的颜色为当前活动?
这是官方指南提供的代码,而这是导致问题的片段.
@Override
public void onConnectionFailed(ConnectionResult result) {
if (mResolvingError) {
// Already attempting to resolve an error.
return;
} else if (result.hasResolution()) {
try {
mResolvingError = true;
result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
} catch (IntentSender.SendIntentException e) {
// There was an error with the resolution intent. Try again.
mGoogleApiClient.connect();
}
} else {
// Show dialog using GooglePlayServicesUtil.getErrorDialog()
mResolvingError = true;
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, REQUEST_RESOLVE_ERROR)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mResolvingError = false;
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
如果我在Service中使用它,当您读取 …