小编joh*_*ohn的帖子

android如何在源代码中隐藏或保护网址链接

我在应用程序中使用url链接从服务器发送和接收数据。如果有人反编译我的apk文件并获取源代码,则可以使用url发送垃圾邮件或进行一些无偿购买!

现在如何保护网址链接?

这是对我使用的服务器的请求示例。(我仍然使用本地服务器,直到完成应用程序为止)

public class GetProduct {

    ArrayList<Product> arrayList;
    ProgressDialog progressDialog;
    String url = "http://192.168.43.46/fasabazar/android/getProductsFullInfo";
    OnProductRecieved onProductRecieved = null;

    public GetProduct(final OnProductRecieved onProductRecieved, final Context context) {
        arrayList = new ArrayList<>();
        progressDialog = new ProgressDialog(context);
        this.onProductRecieved = onProductRecieved;
        JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {

                JSONArray jsonArray = (JSONArray) response;
                progressDialog.dismiss();
                onProductRecieved.OnRecieved(response);
                // Toast.makeText(context, jsonArray.toString(), Toast.LENGTH_SHORT).show();

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });

        progressDialog.show();
        request.setRetryPolicy(new …
Run Code Online (Sandbox Code Playgroud)

security url android android-volley android-security

5
推荐指数
1
解决办法
789
查看次数

如何从视频路径显示视频缩略图?

我想从存储上的视频路径在 ImageView 中显示视频缩略图。是否有采用视频路径并返回缩略图位图的函数?我通过此代码获取视频路径:

public ArrayList<String> getAllMedia() {
  HashSet<String> videoItemHashSet = new HashSet<>();
  String[] projection = {MediaStore.Video.VideoColumns.DATA, MediaStore.Video.Media.DISPLAY_NAME};
  Cursor cursor = getContext().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
  try {
    cursor.moveToFirst();
    do {
      videoItemHashSet.add((cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA))));
    } while(cursor.moveToNext());
    cursor.close();
  } catch(Exception e) {
    e.printStackTrace();
  }
  ArrayList<String> downloadedList = new ArrayList<>(videoItemHashSet);
  return downloadedList;
}
Run Code Online (Sandbox Code Playgroud)

android file imageview video-thumbnails android-bitmap

4
推荐指数
2
解决办法
8709
查看次数

无法为 io.reactivex.Single 创建调用适配器

我想通过改造和 rxjava 连接到服务器。当我使用 call 时它可以工作,一切都很好。但是当尝试使用 rxjava 时,它会遇到麻烦。错误文本:

无法找到 io.reactivex.Single 的调用适配器

在 build.gradle 中我实现了改造适配器。但我不知道问题是什么。这是我的等级:

implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.8'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
Run Code Online (Sandbox Code Playgroud)

api客户端代码:

public class ApiClient {
public static final String BASE_URL="http://192.168.1.100/digikala/";
private static Retrofit retrofit=null;
public static Retrofit getClient(){
    if(retrofit==null){
        retrofit=new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl(BASE_URL)
                .build();
    }

    return  retrofit;
}
Run Code Online (Sandbox Code Playgroud)

api服务代码:

public interface ApiService {

   @GET("readamazing.php")
   Single<List<Product>> getSingleProducts();
 }
Run Code Online (Sandbox Code Playgroud)

主要活动代码:

ApiService apiService=ApiClient.getClient().create(ApiService.class);
apiService.getSingleProducts().subscribeOn(Schedulers.newThread())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new SingleObserver<List<Product>>() {
        @Override
        public void …
Run Code Online (Sandbox Code Playgroud)

android observable retrofit2 rx-java2

0
推荐指数
1
解决办法
2652
查看次数