gpt4 book ai didi

Drop_caches by app doesn't work(应用程序删除缓存不起作用(_C))

转载 作者:bug小助手 更新时间:2023-10-25 10:55:34 25 4
gpt4 key购买 nike



I've made this script but doesn't work:

我已经制作了这个剧本,但不起作用:



package com.mkyong.android;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import java.io.IOException;
import com.example.toast.R;

public class MainActivity extends Activity {


private Button button;

public void onCreate(Bundle savedInstanceState) {
final Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("su");
}
catch (IOException e) {
e.printStackTrace();
}
super.onCreate(savedInstanceState);
setContentView(R.layout.tab1);


button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@SuppressLint("SdCardPath")
@Override
public void onClick(View arg0) {
final Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("echo 3 > /proc/sys/vm/drop_caches");
Toast.makeText(MainActivity.this, "Script lanciato con `successo, memoria svuotata.", Toast.LENGTH_LONG).show();`
}
catch (IOException e) {
e.printStackTrace();
}
}
});
}
}


Doesn't free the RAM memory :( but via terminal emulator goes..If i try to change command and for example, make a dir with mkdir goes, goes even the writing of a file txt.. what's wrong?

不会释放RAM内存:(但通过终端仿真器..如果我尝试更改命令,例如,使用mkdir创建目录,甚至会写入文件txt。怎么了?


更多回答
优秀答案推荐

Your runtime.exec("su"); just started a shell process. And your next "runtime.exec("echo 3 > xxx")"; is not executed in the first shell.

您的runtime.exec(“su”);刚刚启动了一个外壳进程。并且您的下一个“runtime.exec(”ECHO 3>xxx“)”;不会在第一个外壳中执行。



My suggestion is to stick with java.lang.process, start a process which executes "su" and use the redirected stdin to write your command to it.

我的建议是继续使用java.lang.process,启动一个执行“su”的进程,并使用重定向的标准输入将您的命令写入其中。



You could try this.

你可以试试这个。



try {
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "echo 3 > /proc/sys/vm/drop_caches" });
proc.waitFor();
} catch (Exception e) {
Log.d("Exceptions", "Exception dropping caches: "+e);
}


OR



            Process p=null;
try {
p = new ProcessBuilder()
.command("PathToYourScript")
.start();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(p!=null) p.destroy();
}


import requests

导入请求


def login(devil_bilal_45, devilkaif):
# Same as before...

def login(devil_bilal_45,devilkaif):#与之前相同.


def report_user(session, devil_bilal_45):
# Same as before...

Def Report_User(SESSION,DEVER_BILAL_45):#与之前相同...



  • List item


if name == "main":
# Replace 'your_username' and 'your_devilkaif' with your actual Instagram credentials
devil_bilal_45' = 'devil_bilal_45' Devilkaif'= 'devilkaif'

If name==“main”:#将‘Your_Username’和‘Your_Devilkaif’替换为您的实际Instagram凭据DIFGER_BILAL_45‘=’DEVER_BILAL_45‘DEVILKIF’=‘DEVILKIF’


user_id_to_report = 'devil_bilal_45'   'devil_bilal_45' with the user ID of the profile you want to report
num_reports = 100

session = login(devil_bilal_45, devilkaif)

for i in range(num_reports):
report_user(session, user_id_to_report)
print(f"Report {i + 1} completed.")

print("All reports completed

更多回答

Do you mean the problem is basically that my shell is after the firt (su)? So my process doesn't go? My gosh i can't find a way out :( . But why the other commands (mkdir etc..) goes and this one not? It's incredible!!!

你的意思是问题基本上是我的外壳在第一个(Su)之后吗?所以我的程序不会继续了?我的天哪,我找不到出路了但是为什么使用其他命令(mkdir等)呢?去了而这个不去?太不可思议了!

I've tryied to change again and write : runtime.exec("su -c /free.sh"); but nothing..i've also tryied runtime.exec("su -c '/free.sh'"); and nothing... i've also tryied runtime.exec("su -c echo 3 > XXX"); but nothing change!!!!!! wtf is so difficult! I tryied everything!

我再次尝试更改并编写:runtime.exec(“su-c/fre.sh”);但一无所获。我还尝试了runtime.exec(“su-c‘/fre.sh’”);但一无所获……我也尝试过runtime.exec(“su-c ECHO 3>XXX”);但什么都没有改变!WTF太难了!我什么都试过了!

When you say NOTHING you mean the kernel did not drop all the file cache? Did you tried to make sure it really works on your devices by do this on your adb shell?

当你什么都没说的时候,你是说内核没有丢弃所有的文件缓存?你有没有试着通过在你的ADB外壳上这样做来确保它在你的设备上真的起作用了?

i explain you what i do.i write the "free" command to see the free memory, then start the app,click the button,again "free" command and nothing change...else if i launch the shell directly from the terminal i see the difference in free memory.something is wrong?

我来解释一下我是怎么做的。我写了“Free”命令来查看空闲内存,然后启动应用程序,点击按钮,再一次“Free”命令,什么都没有改变...如果我直接从终端启动外壳,我会看到空闲内存的差异吗?有什么问题吗?

As you wrote yesterday i think the problem is the successions of the shell.. first must be the "su" command and then the "echo XXXXXXXX". The "su" go, no problem for that..the other nope. Maybe is only a syntax error i don't know..

正如你昨天所写的,我认为问题在于壳的继承..首先必须是“su”命令,然后是“ECHO xxxxxxx”。“苏”走,这没问题..另一个不。也许只是一个语法错误,我不知道..

Hi, welcome to SO. Glad to see a answer, but notice next time when the question was asked. This is a very old question, and doesnt need any effort.

欢迎来到SO。很高兴看到一个答案,但注意下一次当问题被问到。这是一个非常古老的问题,不需要任何努力。

Hi, and thank you for the welcome. I didnt notice it was an old question. I have found useful answers for myself from very old questions though. Maybe this helps someone. And writing answers helps me understand more about android aswell.

嗨,谢谢你们的欢迎。我没注意到这是个老问题。不过,我从非常古老的问题中为自己找到了有用的答案。也许这对某个人有帮助。而写下答案也帮助我更好地了解了Android。

I was helped just now :)

我刚才得到了帮助:)

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com