我正在使用chriskacerguis/codeigniter-restserver来创建我的其他api服务器,我正在尝试启用api密钥,但问题是即使我按照说明操作,我也无法使用任何密钥进行身份验证,即使所有请求都通过,即使他们在请求中没有api密钥头.
这是我目前的配置
rest.php
$config['rest_keys_table'] = 'keys';
$config['rest_enable_keys'] = TRUE;
$config['rest_key_column'] = 'api_key';
$config['rest_limits_method'] = 'ROUTED_URL';
$config['rest_key_name'] = 'X-API-KEY';
Run Code Online (Sandbox Code Playgroud)
我的表是使用以下sql查询创建的.
CREATE TABLE `keys` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`api_key` varchar(255) NOT NULL,
`level` int(2) NOT NULL,
`ignore_limits` tinyint(1) NOT NULL DEFAULT '0',
`is_private_key` tinyint(1) NOT NULL DEFAULT '0',
`ip_addresses` text,
`date_created` int(11) NOT NULL,
`api_key_activated` enum('yes','no') NOT NULL DEFAULT 'no'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `keys` (`id`, `user_id`, `api_key`, `level`, `ignore_limits`,
`is_private_key`, `ip_addresses`, `date_created`, …Run Code Online (Sandbox Code Playgroud) 应用程序正在向端点发出请求,该端点发送回包含从数据库获取的数据的 json 字符串。这些数据有时可能会变得相当大,大到 4mb,服务器的默认传输编码是分块的,因此当数据足够大时,它会将其分割成块并将其发送到应用程序。问题是 Retrofit 似乎没有立即处理这个问题,并且因 EOF 错误而崩溃。我怎样才能让 Retrofit 或者更确切地说 OkHttp 知道响应可以被分块?
我正在使用React Navigation在屏幕之间路由.我有一个初始屏幕,其中包含一个FlatList项目的onclick,我路由到一个新的屏幕,同时传递这样的参数.
props.navigation.navigate('Details', {
id: props.id,
title: props.title
});
Run Code Online (Sandbox Code Playgroud)
在Details屏幕上,我可以使用以下代码接收它,但如何设置状态,因为它是一个静态函数,我无权访问this.setState().
static navigationOptions = ({navigation}) => {
const {params} = navigation.state;
console.log(params);
};
Run Code Online (Sandbox Code Playgroud) reactjs react-native react-native-android react-native-navigation react-navigation
我正在使用android studio 2.3 beta 1以及这些配置
compileSdkVersion 25
buildToolsVersion"25.0.2"
applicationId"octave.foodster"
minSdkVersion 19
targetSdkVersion 25
问题是,当我通过Android工作室运行应用程序一切正常但当我将同一个应用程序的apk发送到另一部手机时,它崩溃.我只是使用基本活动所以只是android工作室创建的时刻的默认模板你创建一个新项目.我没有添加任何外部库或其他任何东西.
清单文件
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
E/AndroidRuntime: FATAL EXCEPTION: main
Process: octave.foodster, PID: 8580
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{octave.foodster/octave.foodster.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "octave.foodster.MainActivity" on path: DexPathList[[zip file "/data/app/octave.foodster-1/base.apk"],nativeLibraryDirectories=[/data/app/octave.foodster-1/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2566)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1572)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5896)
at java.lang.reflect.Method.invoke(Native …Run Code Online (Sandbox Code Playgroud) 我正在使用android数据绑定,我想从编辑文本数据创建一个observable,所以我可以使用rxjava对它进行操作.这是我的代码.
XML
<EditText
android:id="@+id/edit_text_username"
android:layout_width="match_parent"
android:addTextChangedListener="@{viewModel.getUsername}"
android:background="@drawable/border_edit_top"
android:drawableLeft="@drawable/ic_person_white_24px"
android:drawablePadding="10dp"
android:drawableStart="@drawable/ic_person_white_24px"
android:hint="@string/username"
android:inputType="text"
android:paddingEnd="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingStart="10dp"
app:layout_heightPercent="10%" />
Run Code Online (Sandbox Code Playgroud)
ViewModel类
public TextWatcher getUsername() {
return new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log.i("username", s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
};
}
Run Code Online (Sandbox Code Playgroud)
我有3个这样的编辑文本,我想使用rx java的combinelatest运算符进行表单验证.我在这个场景中如何实现rx java?
在这里尝试使用云功能进行一些小技巧,但似乎无法弄清楚问题是什么。
我目前正在使用 now.sh 来托管无服务器函数,并希望从另一个函数调用 1 个函数。假设我声明了 2 个函数fetchData& setData。setData调用该fetchData函数时,它会处理一些数据,然后调用该函数。
export const setData = async (req: Request, res: Response) => {
await axios.post(
fetchDataEndpointUrl,
{
params: {
key,
},
},
);
return res.json({
payload: true,
});
}
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,但完成整个操作所需的时间将是 setData 函数调用 + 完成 fetchData 函数调用所需的时间。我想要做的是调用 ,fetchData而不必等待它完成基本上删除awaitaxios 调用中的 。我试过删除,await但当通话结束时setData通话突然结束。有没有办法解耦这个动作而不必等待setData函数完成?
Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
Log.i("frag", "onCreate");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true);
final View view = inflater.inflate(R.layout.fragment_initiate_chat, container, false);
bindViews(view);
setUpClickListener();
setUpCategories(view);
return view;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
//menu.clear();
inflater.inflate(R.menu.menu_inititate_chat, menu);
Log.i("frag", "onCreateOptionsMenu");
//super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.i("frag", "onOptionsItemSelected");
final int itemId = item.getItemId();
switch (itemId) {
case R.id.send:
sendIssue();
break;
}
return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)
我无法为我的片段设置菜单。我使用了 setHasOptionsMenu(true); 但它仍然没有任何区别。
我的片段 …
我收到一个通知,我想创建一个自定义的Back Stack,以便用户可以浏览它。但是到目前为止,单击通知会打开所需的活动,但是当我按下Back按钮时,它会完全退出该应用程序。
Intent resultIntent = new Intent(this, NotifViewActivity.class);
resultIntent.putExtra(StringHolder.NOTIFICATION_ID, notif.getId());
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(HomeActivity.class);
stackBuilder.addParentStack(NotifActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationCompat = new NotificationCompat.Builder(context)
.setAutoCancel(true)
.setContentTitle(notif.getTitle())
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(resultPendingIntent);
Run Code Online (Sandbox Code Playgroud)
清单文件
<activity
android:name=".NotifActivity"
android:parentActivityName=".HomeActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
</activity>
<activity
android:name=".NotifViewActivity"
android:parentActivityName=".NotifActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".NotifActivity" />
</activity>
Run Code Online (Sandbox Code Playgroud)
我希望它的工作方式是,在单击通知时,将用户转到 NotifViewActivity,然后在按下后退按钮时,将用户转到NotifActivity;当再次按下后退按钮时,将用户 转到 HomeActivity。正在尝试创建,我该怎么做?
android android-intent android-notifications android-pendingintent taskstackbuilder
我正在设计一个聊天项目,其外观应类似于whatsapp风格的聊天界面,但问题是左侧约束似乎不起作用。
这是我的代码。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline
android:id="@+id/left_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.20" />
<LinearLayout
android:id="@+id/chat_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/chat_sender_bubble"
android:orientation="vertical"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toRightOf="@id/left_guideline"
app:layout_constraintRight_toRightOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="22dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="22dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<ImageView
android:id="@+id/sender_image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:adjustViewBounds="true"
android:background="@color/transparent"
android:scaleType="center"
android:src="@mipmap/ic_launcher"
android:visibility="gone" />
<TextView
android:id="@+id/sender_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginBottom="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="This is a really long message that could cross the
left guideline."
android:textColor="@color/senderBubbleTextColor" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/sender_timestamp" …Run Code Online (Sandbox Code Playgroud) android android-layout android-linearlayout android-xml android-constraintlayout
我已按照此页面上的说明进行操作,但YouTube Android Player API已成功运行,但是尽管已下载了YouTubeAndroidPlayerApi jar文件,但如果我尝试在没有youtube应用程序的设备上运行该应用程序,则会引发错误请求更新到最新的youtube版本。有没有一种方法可以将youtube视频嵌入到应用程序中,而不依赖于拥有youtube应用程序的应用程序用户或不在其设备上的用户?
我已经检查了其他问题,其中大多数建议将网页视图加载到iframe或webview中。我想知道截至2018年是否有可用的解决方案,还是仍然不可能?
附言:我希望将视频本身嵌入,而不是将其加载到Webview中。
我试图从子类调用父类的函数,但关键字super是抛出和错误。我正在使用打字稿,这是项目中 package.json 的一个片段。
{
"scripts": {
"build": "tsc",
"start": "nodemon",
"prod": "npm run build && npm run start"
},
"dependencies": {
"body-parser": "^1.18.3",
"dotenv": "^6.1.0",
"express": "^4.16.4"
},
"devDependencies": {
"@types/body-parser": "^1.17.0",
"@types/dotenv": "^4.0.3",
"@types/express": "^4.16.0",
"@types/node": "^10.12.2",
"nodemon": "^1.18.5",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.1.6"
}
}
Run Code Online (Sandbox Code Playgroud)
父类
export default class baseController {
public response = (message = "", status = 200) => (
req: Request,
res: Response
) => {
return res.status(status).send({
status: true, // true …Run Code Online (Sandbox Code Playgroud) 这是我最初在build.gradle文件中的内容.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.clans:fab:1.6.1'
compile 'joda-time:joda-time:2.8.2'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.afollestad:material-dialogs:0.7.9.1'
compile 'com.wdullaer:materialdatetimepicker:1.5.3'
compile 'com.android.support:palette-v7:23.0.1'
}
Run Code Online (Sandbox Code Playgroud)
库材料对话框已更新,所以我试图在我的gradle文件中反映相同.图书馆说我应该像这样添加它.
dependencies {
compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') {
transitive = true
}
}
Run Code Online (Sandbox Code Playgroud)
所以我尝试了这个,但是当我尝试这个时它拒绝重建项目,并且错误地说"未能解决:com.afollestad.material-dialogs:core:0.8.1.0"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.clans:fab:1.6.1'
compile 'joda-time:joda-time:2.8.2'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.wdullaer:materialdatetimepicker:1.5.3'
compile 'com.android.support:palette-v7:23.0.1'
compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') …Run Code Online (Sandbox Code Playgroud) 我有一个包含一组对象的arraylist。我想使用rxjava,这样我就可以通过onSubscribe方法循环遍历列表,而不是一次获取整个列表,而是一次获取每个列表项
android ×9
java ×4
javascript ×2
node.js ×2
rx-java2 ×2
typescript ×2
android-menu ×1
android-xml ×1
api-key ×1
arraylist ×1
codeigniter ×1
dependencies ×1
dex ×1
express ×1
gradle ×1
material ×1
okhttp ×1
php ×1
postman ×1
react-native ×1
reactjs ×1
rest ×1
retrofit ×1
retrofit2 ×1
rx-android ×1
rx-java ×1
tsconfig ×1
vercel ×1
webview ×1
youtube ×1