我已经编写了这个脚本,但不起作用:
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();
}
}
});
}
}
不释放RAM内存:(但是通过终端模拟器去..如果我尝试更改命令,例如,使用mkdir创建一个目录,甚至写入文件txt也会去..出了什么问题?
您的
runtime.exec("su");
刚刚启动了一个shell进程。并且您的下一个 "runtime.exec("echo 3 > xxx")";
不会在第一个 shell 中执行。
我的建议是坚持使用 java.lang.process,启动一个执行“su”的进程,并使用重定向的标准输入向其写入命令。
你可以试试这个。
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);
}
或
Process p=null;
try {
p = new ProcessBuilder()
.command("PathToYourScript")
.start();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(p!=null) p.destroy();
}
导入请求
def 登录(devil_bilal_45,devilkaif): # 和以前一样...
def report_user(会话,devil_bilal_45): # 和以前一样...
if name == "main": # 将“your_username”和“your_devilkaif”替换为您的实际 Instagram 凭据
devil_bilal_45' = 'devil_bilal_45'
Devilkaif'='devilkaif'
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