我有一个服务的应用程序.服务由app在create method的主要活动中启动.我退出应用程序时出现问题:服务停止,有时立即重启,有时最近重启.我在4.1.2版和2.3.6版中测试过.版本2.3.6中不再提供服务.我的方法有误吗?在停止和重新启动时间之间,必须阻止的呼叫可以到来.退出应用程序时有没有办法停止服务?注意:我无法使用远程服务.
我添加了startForeground服务,但同样的问题.当我退出应用程序服务停止而不重启版本2.3.3甚至我看到notification.But phoneStateListener取空值我怎样才能确保当我退出应用程序时,服务不会停止
//application main metod
@Override
protected void onCreate(Bundle savedInstanceState) {
//.....
startService(new Intent(getApplicationContext(), MyPhoneStateListener.class));
}
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
setCallListener();
setNoti();
return START_STICKY;
}
private void setCallListener()
{
try
{
if (phoneStateListener==null)
{
phoneStateListener = new StateListener();
telephonymanager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
telephonymanager.listen(phoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
}
}
catch(Exception ex)
{
}
}
Run Code Online (Sandbox Code Playgroud)
private void setNoti(){
Notification notification= new Notification(R.drawable.ic_launcher, getResources().getString(R.string.app_name), System.currentTimeMillis());
Intent main = new Intent(this, MainActivity.class);
main.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, …Run Code Online (Sandbox Code Playgroud) 我有两份工作。第一个是使用一些参数手动触发的(例如需要的数字)。我有第二份工作,它使用参数来选择上一份工作的特定构建(运行参数)。
现在,我需要从第一份工作中获取参数(在本例中为数字),第二份工作也需要这些参数。我想防止让用户第二次给出 number 参数。
与此同时,我找到了一种通过以下方式从第一个作业中提取参数的方法:
@NonCPS
def getParameters(def item) {
def result = ""
def p = item?.actions.find{ it -> it instanceof ParametersAction }?.parameters
p.each { it ->
echo "parameter ${it.name}: ${it.value}"
if (it.name.equals("NUMBER")) {
result = it.value.toString()
}
}
return result
}
...
node (..) {
def item = hudson.model.Hudson.instance.getItem("${SELECTED_JOBNAME}")
def number = Integer.parseInt("${SELECTED_NUMBER}")
def x = item.getBuildByNumber(number)
def newNumber = getParameters(x)
Run Code Online (Sandbox Code Playgroud)
出现的问题是得到以下内容:
parameter NUMBER: 16
[Pipeline] echo
org.jenkinsci.plugins.workflow.job.WorkflowJob@1776388d[XX-YY]
[Pipeline] echo
XX-YY #48
[Pipeline] echo
newNumber: 16
[Pipeline] stage …Run Code Online (Sandbox Code Playgroud) 我想将textview与EditView的垂直中心对齐

我的布局如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="text1"/>
<EditText
android:id="@+id/setup_homeid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:maxLength="5"
android:inputType="number"
android:hint=""/>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我怎么能实现它?
提前致谢
我在运行应用程序时遇到此活动崩溃.这不是由于appcompat,因为您可以在堆栈跟踪中看到.这是本机android ListView类,在运行应用程序时找不到该方法.
相同的应用程序在其他设备上正常运行.minSdkVersion = 13 target = 23 max = 23,崩溃的当前设备是API 17.
FATAL EXCEPTION: main
java.lang.NoSuchMethodError: android.widget.ListView.setElevation
at com.example.saloni.laughgurumarketingapp.ContentDetails.getValues(ContentDetails.java: 392)
at com.example.saloni.laughgurumarketingapp.ContentDetails.onCreate(ContentDetails.java: 298)
at android.app.Activity.performCreate(Activity.java: 5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1081)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2358)
at android.app.ActivityThread.access$600(ActivityThread.java: 156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java: 1340)
at android.os.Handler.dispatchMessage(Handler.java: 99)
at android.os.Looper.loop(Looper.java: 153)
at android.app.ActivityThread.main(ActivityThread.java: 5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java: 511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: 600)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
在代码中,它只是一个设置的提升方法,正如您在跟踪中看到的那样,它正在崩溃.同样,它上次使用其中一个TextView类方法时崩溃了.为什么会这样?
我正在运行一个用于在Android 5.1上运行的旧代码.现在它无法使用以下错误FileOutputStream ( EACCES (Permission denied) ).
任何输入?
码:
package com.example.digitaljalebi_uno.syncserver;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.widget.TextView;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.Enumeration;
/*
* Permission needed:
* <uses-permission android:name="android.permission.INTERNET"/>
* <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
*/
public class MainActivity extends Activity {
TextView infoIp, infoPort;
static final int SocketServerPORT = 8080;
ServerSocket serverSocket;
ServerSocketThread …Run Code Online (Sandbox Code Playgroud) 所以我正在为一项作业制作应用程序.
基本上将里程转换为KM或KM到Miles.
我现在已经有了单选按钮,但是当我添加onclick事件时,单击edittext字段后我得到了一个异常.:
java.lang.IllegalArgumentException:
Expected receiver of type a00891437.set3s.comp3975.convertunits.MainActivity,
but got android.support.v7.internal.widget.TintContextWrapper
Run Code Online (Sandbox Code Playgroud)
这是代码
package a00891437.set3s.comp3975.convertunits;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks …Run Code Online (Sandbox Code Playgroud) 在测试管理员和SOA服务器后,我安装了BPM并关闭了VM,然后从oracle网站下载了带有Oracle 12c 12.2.1.1的新VM。
现在,当我尝试启动Jdeveloper时,出现以下错误:
Oracle JDeveloper 12c Development Build 12.2.1.1.0
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
java.lang.RuntimeException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:233)
at org.eclipse.osgi.framework.internal.core.Framework.launch(Framework.java:664)
at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.internalInit(EquinoxLauncher.java:69)
at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.init(EquinoxLauncher.java:37)
at org.eclipse.osgi.launch.Equinox.init(Equinox.java:178)
at org.netbeans.modules.netbinox.Netbinox.init(Netbinox.java:84)
at org.netbeans.core.netigso.Netigso.prepare(Netigso.java:167)
at org.netbeans.NetigsoHandle.turnOn(NetigsoHandle.java:138)
at org.netbeans.ModuleManager.enable(ModuleManager.java:1346)
at org.netbeans.ModuleManager.enable(ModuleManager.java:1163)
at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:340)
at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:276)
at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:301)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:181)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:150)
at org.netbeans.core.startup.Main.start(Main.java:307)
at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.resume(InternalSystemBundle.java:225)
... …Run Code Online (Sandbox Code Playgroud)