我有一个问题是将位图保存到文件中.我的方法是这样的:
private File savebitmap(Bitmap bmp) {
String extStorageDirectory = Environment.getExternalStorageDirectory()
.toString();
OutputStream outStream = null;
File file = new File(bmp + ".png");
if (file.exists()) {
file.delete();
file = new File(extStorageDirectory, bmp + ".png");
Log.e("file exist", "" + file + ",Bitmap= " + bmp);
}
try {
outStream = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
} catch (Exception e) {
e.printStackTrace();
}
Log.e("file", "" + file);
return file;
}
Run Code Online (Sandbox Code Playgroud)
它给了我file的错误.我这样调用这个方法:
Drawable d = iv.getDrawable();
Bitmap bitmap = ((BitmapDrawable) d).getBitmap();
File …Run Code Online (Sandbox Code Playgroud) 我在应用程序中的实现就像我的 WooCommerce 网站一样。我想在计算运费时实现以下几点:
到目前为止,我实现的是第 4 点。我能够通过网站计算所有运输方式,但如果不是通过网站计算,那么它会在那里返回 null。
这是我的 API 代码:
function register_get_cart_shipping() {
register_rest_route(
'custom-plugin', '/getCartShipping/',
array(
'methods' => ['GET'],
'callback' => 'getCartShipping',
)
);
function getCartShipping() {
$chosen_methods = WC()->session->get('chosen_shipping_methods');
$count = 0;
foreach( WC()->session->get('shipping_for_package_0')['rates'] as $method_id => $rate ){
$data[$count]->rate_id = $rate->id;
$data[$count]->method_id = $rate->method_id;
$data[$count]->instance_id = $rate->instance_id;
$data[$count]->label = $rate->label;
$data[$count]->cost = $rate->cost;
$data[$count]->taxes = $rate->taxes;
$data[$count]->chosen = $chosen_methods['rate_id'];
if($chosen_methods['rate_id'] == $rate->id ){
$data[$count]->isSelected = true;
} else {
$data[$count]->isSelected = false; …Run Code Online (Sandbox Code Playgroud) php android woocommerce woocommerce-rest-api shipping-method
我正在开发一个带有 Firebase 用户身份验证的 Android 应用程序。我面临的问题是我从用户那里获取电子邮件和密码,然后将该用户创建到 firebase 中。我没有验证用户输入的电子邮件。现在我想实现重置密码功能。为此,Firebase 提供了 ResetPassword 方法并向该特定用户发送重置密码电子邮件。但问题是,如果电子邮件不存在那我们该怎么办?
这是我用来在 Firebase 中注册用户的代码:
private void registerUser(){
//creating a new user
firebaseAuth.createUserWithEmailAndPassword("user email here", "user password here")
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
//checking if success
if(task.isSuccessful()){
//display some message here
}else{
//display some message here
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
如果此功能有任何替代选项,请告诉我。谢谢。