Tag: 安卓

如何通过.apk传递dalvik命令行参数?

我知道有可能以这种方式在Android中启动java程序: adb push “hello_world.zip” $REMOTE_PATH/ adb shell mkdir $REMOTE_PATH/dalvik-cache adb shell dalvikvm -cp “$REMOTE_PATH/hello_world.zip” -Xint:portable -Xdexopt:none -Xverify:none hello_world 这很好! 但现在我想创建Android .apk文件。 我希望这个应用程序能够使用相同的命令行参数”-Xint:portable -Xdexopt:none -Xverify:none”自动启动。 我假设参数名称可能与此”-Xint:portable -Xdexopt:none -Xverify:none” ,但function必须相同。 我不知道我要做什么,谷歌不想帮我解决这个问题。 任何帮助将非常感激!

Android – 1除以2 = 0

我一直在尝试使用我的新IOIO for android,并且需要找到信号的频率。 所以我将信号转换为二进制,然后将1除以1之间的时间。 虽然当我这样做时,我发现我的输出为0。 然后我决定看看1/2给了我什么,令我惊讶的是它也给了0! 任何人都知道为什么会这样吗? 代码: private float frequency = 1/2; 这可能是使用Float.toString(frequency)吗?

Android studio – 如何保存以前活动中选择的数据

这是我的代码片段。 Textview充当按钮并在Onclicklistner上具有Onclicklistner 。 当单击cpu1000 Textview ,它将导致cpu_g1000类,其代码如下所示。 public class Game_1000 extends AppCompatActivity implements View.OnClickListener{ private TextView cpu1000, mobo1000; TextView cpu, mobo; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_game_1000); cpu1000 = (TextView) findViewById(R.id.proName_G1); mobo1000 = (TextView) findViewById(R.id.moboName_G1); cpu1000.setOnClickListener(this); mobo1000.setOnClickListener(this); cpu = (TextView) findViewById(R.id.proNameG1000); cpu.setText(getIntent().getStringExtra(“Processor”)); mobo = (TextView) findViewById(R.id.moboNameG1000); mobo.setText(getIntent().getStringExtra(“Motherboard”)); } @Override public void onClick(View v) { […]

如何知道其他应用何时开始启动?

可能重复: Android:应用程序Protector应用程序如何工作? 如何在新应用程序开始启动时收到通知? 很清楚地说,我点击应用程序图标,应用程序开始启动,我想将我的服务设置为该事件的观察者(如果有的话)。 在应用推出之前是否有任何事件或某种方式可以知道?

Android NDK使用不同的命名空间调用本机方法

我是JNI编程的新手我可以从不同的JNI命名空间定义中调用本机方法吗? 例如: package com.example.hellojni; public class HelloJni extends Activity { public native int MyMethod(); public native int OtherMethod(); // this works have the namespace package=jniexport interface static {System.loadLibrary(“hello-jni”);} @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int b = OtherMethod(); //works int a = MyMethod(); //ERROR java.lang.reflect.InvocationTargetException } } ================File.c================ JNIEXPORT int JNICALL Java_Cardioline_HelloJni_MyMethod(JNIEnv *env, jobject […]

Android耳机检测

我有一个应用程序,可以向用户说短信。 我想这样做,以便当用户点击一个名为“Headphones on”的按钮时,应用程序只会在检测到耳机时与之通话。 是否有一个命令可以让我检测耳机是否插入?

Firebase在Android上自动重新连接

这是我的代码: firebaseRef.getRoot().child(“.info/connected”).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { if (snapshot.getValue(Boolean.class)) { // We’re connected (or reconnected)! Set up our presence state. firebaseRef.child(“child”).setValue(“value”); } } @Override public void onCancelled() { } }); “孩子”路径的安全规则: “.write”: (auth != null); 当客户端断开连接然后重新连接setValue(“value”); 应该工作。 它在JS SDK上完美运行。 但是,Java SDK似乎有重新解决的问题。 它不能setValue(“value”) ,Firebase返回Permission denied错误。 那里有什么不对吗? 请帮忙。 谢谢!

不同的OnClickListener实现方式

有什么区别: public class MainActivity extends Activity { public void onCreate (Bundle savedInstanceState) { button1 = (Button) findViewById(R.id.btn1); button1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // Click code } )}; } } 和: public class MainActivity extends Activity implements OnClickListener { public void onCreate (Bundle savedInstanceState) { button1 = (Button) findViewById(R.id.btn1); button1.setOnClickListener(this); } public […]

在我的应用程序中获取错误“java.lang.RuntimeException:无法启动活动”

我的申请昨天工作,我无法弄清楚为什么它停止工作。 我唯一想做的就是创建一个签名的apk。 为此,我必须创建一个新的Google地图密钥并将其放入清单文件中。 我按照Google开发人员教程完成了这项工作。 但是现在当我尝试运行它启动时,我点击一个按钮就会强行关闭。 这是错误日志: 03-20 23:31:33.636 10036-10036/project.sharethefare E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: project.sharethefare, PID: 10036 java.lang.RuntimeException: Unable to start activity ComponentInfo{project.sharethefare/project.sharethefare.CurrentLocation}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725) at android.app.ActivityThread.access$900(ActivityThread.java:172) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5834) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388) at […]

Android通知不会发出声音或振动

int icon = R.drawable.icon; Context context = getApplicationContext(); CharSequence contentTitle = “My notification”; CharSequence contentText = “Countdown Complete!”; NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(); Notification notification = new Notification(icon, “is completed!”, System.currentTimeMillis()); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, contentTitle, contentText, pendingIntent); long[] vibrate = {0,100,200,300}; notification.vibrate = vibrate; notification.defaults […]