我正在尝试为Amazon Web Services创建一个用户帐户,以便在凭据受到威胁时限制我的风险.
我已经设置了一个具有凭据的测试用户,并且我正在尝试创建自定义权限,因此这些凭据只能用于极其有限的目的.然后它询问我带有显示工具提示的ARN.我不知道如何格式化它.
我的ARN应该是这样的吗?
阿尔恩:AWS:SDB :::域/
要么?
:XXXX-XXXX-XXXX:TESTDOMAIN
我使用安全的后端创建了一个端点,并且自从3月份开始在我正在构建的应用程序中使用它(源文档在这里).我最近在我的Android 6.0设备上安装了最新版本,弹出了一个奇怪的错误(它在4.2.2和5.1上完美运行).
具体错误是:
IllegalArgumentException: the name must not be empty: null
Run Code Online (Sandbox Code Playgroud)
我跟踪了凭证的错误,您可以看到下面的代码.在Android 6.0帐户可能是"user@gmail.com"但字符串'test'结果为null!
有什么特定的6.0改变了GoogleAccountCredential吗?
public static GoogleAccountCredential getCredential(Context ctx) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
String account = prefs.getString(UserProfileHelper.PREF_USER_ACCOUNT, "");
GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(ctx,
"server:client_id:MY_ACCOUNT_NUMS.apps.googleusercontent.com")
.setSelectedAccountName(account);
String test = credential.getSelectedAccountName();
return credential;
}
Run Code Online (Sandbox Code Playgroud) google-app-engine android credentials google-account google-cloud-endpoints
我有以下代码创建我的表.我将数据插入其中,看起来像这样
_id date recordName total
--------------------------------------
7 2011 TestMaxRecord 5
Run Code Online (Sandbox Code Playgroud)
Java代码:
public static final String KEY_ROWID = "_id";
public static final String KEY_DATE = "date";
public static final String KEY_TOTAL = "total";
public static final String KEY_RECORD_NAME = "recordName";
private static final String DATABASE_CREATE_RECORDS = "create table " + DATABASE_TABLE_RECORDS + " ("
+ KEY_ROWID + " integer primary key autoincrement, "
+ KEY_DATE + " text not null, "
+ KEY_RECORD_NAME + " text not null, "
+ KEY_TOTAL …Run Code Online (Sandbox Code Playgroud) 我无法让Action Bar显示我的操作项.它们都出现在溢出菜单中.我已粘贴下面的所有相关代码.谁能看到我的问题?
来自活动:
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater mi = getMenuInflater();
mi.inflate(R.menu.viewer_menu, menu);
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_download:
return true;
case R.id.menu_star:
return true;
case R.id.menu_report:
return true;
case android.R.id.home:
// app icon in action bar clicked; go home
finish();
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
从清单:
<activity android:name=".CustomActivity"
android:label="">
Run Code Online (Sandbox Code Playgroud)
来自values-v11文件夹(themes.xml)
<resources>
<style name="MyTheme" parent="@android:style/Theme.Holo">
</style>
Run Code Online (Sandbox Code Playgroud)
来自菜单文件夹(viewer_menu.xml)
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_download"
android:title="Download" showAsAction="withText"
android:orderInCategory="2"/>
<item android:id="@+id/menu_star"
android:icon="@android:drawable/ic_menu_upload"
android:title="Star" …Run Code Online (Sandbox Code Playgroud) 有谁知道如何更改图例的位置?我正在尝试扩展图表以利用所有空间.
到目前为止我有
mRenderer.setMargins(new int [] {20,30,-50,0});
这会将图形向下扩展,但图例保持在相同位置,因此它现在位于x轴上方
我试过了
mRenderer.setLegendHeight(5);
同时具有消极和正面价值.我不确定这应该做什么,但是它使我的图形在屏幕上变得很低(将其变成可滚动的视图).
此外,可能不重要,但这是一个片段,是XYChart类型.
我正在尝试使用带有Objectify和Google App Engine的光标来返回数据和光标的子集,这样我就可以在用户准备好时检索更多数据.我在这里找到了一个看起来完全像我需要的例子,但我不知道如何返回最终列表和光标.这是我的代码:
@ApiMethod(name = "listIconThemeCursor") //https://code.google.com/p/objectify-appengine/wiki/Queries#Cursors
public CollectionResponse<IconTheme> listIconThemeCursor(@Named("cursor") String cursorStr) {
Query<IconTheme> query = ofy().load().type(IconTheme.class).limit(10);
if (cursorStr != null ) {
query.startAt(Cursor.fromWebSafeString(cursorStr));
}
List<IconTheme> result = new ArrayList<IconTheme>();
int count = 0;
QueryResultIterator<IconTheme> iterator = query.iterator();
while (iterator.hasNext()) {
IconTheme theme = iterator.next();
result.add(theme);
count++;
}
Cursor cursor = iterator.getCursor();
String encodeCursor = cursor.toWebSafeString();
return serial(tClass, result, encodeCursor);
}
Run Code Online (Sandbox Code Playgroud)
请注意,这是从先前的端点修改的,在该端点中我返回了所有数据的CollectionResponse.我的数据集足够大,不再实用.基本上,我不知道用户的'serial(tClass,result,encodeCursor)函数是什么让它返回给用户.
这里有另一个例子,但似乎也没有回答我的问题.
我无法让ViewModel组件与Proguard一起工作.我已经不得不添加以下内容以防止由于NoSuchMethodException导致崩溃:init()
-keep class com .... SlideshowViewModel {*;}
但是,我在活动中的观察者没有收到任何数据.这个工作正常,直到我启用Proguard,所以我知道Proguard是原因,我只是不知道为什么(新手Proguardian在这里).我需要添加什么规则才能使可观察量有效?
我的ViewModel(Kotlin)中有以下内容
val currentItem = MediatorLiveData<MediaItem>()
Run Code Online (Sandbox Code Playgroud)
....后来...
Timber.d("Setting next image: " + position + " out of " + mediaItemList.size)
currentItem.value = mediaItemList[position]
Run Code Online (Sandbox Code Playgroud)
和活动(Java)
viewModel.getCurrentItem().observe(this, new Observer<MediaItem>() {
@Override
public void onChanged(@Nullable final MediaItem mediaItem) {
Timber.d("Activity received new item");
}
});
Run Code Online (Sandbox Code Playgroud)
在我收到的日志中:D/SlideshowViewModel:设置下一张图片:18中的0
但是在onChanged Observable中没有任何东西被解雇.
我在AsyncTask中有以下代码.name是"item","setMax"或"创建数据库(这是一次性函数)"之类的句子.
当我将"item"传递给代码时代码增加1然后它将消息设置为"item Please wait ..."时出现问题.我认为这是因为它应该是If/Else If/Else顺序但我不确定.是否有更有效的方法或我应该定义常量并使用switch语句?
protected void onProgressUpdate(String... name) {
if (name[0].equals("item")) {
mDialog.incrementProgressBy(1);
} if (name[0].equals("setMax")) {
mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mDialog.setMax(Integer.parseInt(name[1]));
} else {
mDialog.setMessage(name[0] + " Please wait...");
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用AsyncTask下载一个带有progressdialog的数据库,该数据库显示了UI的进度.我的一些用户收到错误:
CalledFromWrongThreadException:只有创建视图层次结构的原始线程才能触及其视图.
据我所知,只有在尝试从UI线程更新Views时才会发生这种情况.这是错误:
com ... updateops.DbCreate.onProgressUpdate(DbCreate.java:70)at com ... updateops.DbCreate.onProgressUpdate(DbCreate.java:1)
这是我的代码:
public class DbCreate extends AsyncTask<String, String, String>{
private static Context mCtx;
private static ProgressDialog mDialog;
public static AmazonSimpleDBClient mSDbClient;
public static AmazonS3Client mS3Client;
private static int mAppVersion;
private static boolean mCreate;
public DbCreate(Context ctx, int versionCode, boolean create) {
mCtx = ctx.getApplicationContext();
mAppVersion = versionCode;
mDialog = new ProgressDialog(ctx);
mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mDialog.setMessage("Checking for server access. Please wait...");
mDialog.setCancelable(false);
mDialog.setMax(1);
mDialog.show();
mCreate = create;
}
protected void onProgressUpdate(String... name) {
if (name[0].equals("item")) …Run Code Online (Sandbox Code Playgroud) 我希望有人可以帮助我解决这个问题.我无法重现此错误,但收到了大量的崩溃报告.下面是堆栈跟踪和相关代码.我想添加"cursor.close();" 会解决问题,但事实并非如此.任何人都可以弄明白发生了什么?第187行是mDbAdapter.close();
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.companionfree.WLThemeViewer/com.companionfree.WLThemeViewer.Viewer}: android.database.sqlite.SQLiteException: unable to close due to unfinalised statements
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2753)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.access$2500(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2117)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: unable to close due to unfinalised statements
at android.database.sqlite.SQLiteDatabase.dbclose(Native Method)
at android.database.sqlite.SQLiteDatabase.onAllReferencesReleased(SQLiteDatabase.java:323)
at android.database.sqlite.SQLiteDatabase.close(SQLiteDatabase.java:886)
at android.database.sqlite.SQLiteOpenHelper.close(SQLiteOpenHelper.java:191)
at com.companionfree.WLThemeViewer.DbAdapter.close(DbAdapter.java:163)
at com.companionfree.WLThemeViewer.Viewer.getNavData(Viewer.java:178)
at com.companionfree.WLThemeViewer.Viewer.onCreate(Viewer.java:65)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
... 11 more
Run Code Online (Sandbox Code Playgroud)
资源:
private void getNavData() {
mDbAdapter.open(); …Run Code Online (Sandbox Code Playgroud) android ×8
sqlite ×2
achartengine ×1
amazon ×1
credentials ×1
exception ×1
fragment ×1
if-statement ×1
java ×1
legend ×1
objectify ×1
proguard ×1
viewmodel ×1