在我的Android应用程序中,我必须使用相机按钮click.It工作完美的所有Android版本除了安卓7(牛轧糖).当我点击相机选项,即使权限打开,应用程序即将退出.我认为问题出在相机调用intent.Below是我的代码.
camera = (ImageView) dialog.findViewById(R.id.camera);
camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickCamera();
dialog.dismiss();
}
});
private void clickCamera() { // 1 for icon and 2 for attachment
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.CAMERA }, MY_REQUEST_CODE);
} else {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, MY_REQUEST_CODE_STORAGE);
} else {
currentImageUri = getImageFileUri();
Intent intentPicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intentPicture.putExtra(MediaStore.EXTRA_OUTPUT, currentImageUri); // set the image file name
// start …Run Code Online (Sandbox Code Playgroud) 在我的 android 项目中,我有一个同步适配器,可以将数据从 android 设备同步到服务器并且工作正常,但最近我注意到 onPerfomSync 没有在我的 moto g3 android 手机中调用,我不知道是否有在任何其他手机上都有同样的问题,我在其他一些具有不同 android api 级别的三星手机上进行了测试,但没有发现任何问题。我已经配置了用户登录成功时的同步。这是什么原因行为。如果我做错了什么,请纠正我。下面是我的代码。
private void finishLogin(Intent intent) {
String accountName = intent.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
String accountPassword = intent.getStringExtra(PARAM_USER_PASS);
final Account account = new Account(accountName, intent.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE));
if (getIntent().getBooleanExtra(ARG_IS_ADDING_ACCOUNT, false)) {
String authtoken = intent.getStringExtra(AccountManager.KEY_AUTHTOKEN);
String authtokenType = authTokenType;
String refreshToken = intent.getStringExtra(KEY_REFRESH_TOKEN);
Bundle userData = new Bundle();
userData.putString(KEY_REFRESH_TOKEN, refreshToken);
accountManager.addAccountExplicitly(account, accountPassword, userData);
accountManager.setAuthToken(account, authtokenType, authtoken);
accountManager.setUserData(account,KEY_REFRESH_TOKEN,refreshToken);
ContentResolver.setMasterSyncAutomatically(true);
ContentResolver.setSyncAutomatically(account, "com.myexample.mysampleproject", true);
configurePeriodicSync(account, SYNC_INTERVAL, SYNC_FLEXTIME);
try {
} catch (Exception e) {
e.printStackTrace();
} …Run Code Online (Sandbox Code Playgroud) android synchronization android-contentprovider android-syncadapter
在我的Android应用程序中,我使用rest模板进行服务调用,但问题是现在我在调用任何服务时遇到错误.服务未连接到服务器.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.lss.company, PID: 8611
java.lang.NoClassDefFoundError: org.springframework.web.util.UriTemplate
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:498)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:447)
at com.lss.company.services.ServerAuthenticateService.getAllEmployeeList(ServerAuthenticateService.java:7320)
at com.lss.company.view.LoginActivity.onCreate(LoginActivity.java:138)
at android.app.Activity.performCreate(Activity.java:5459)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5598)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
下面是build.gradle依赖项代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.lss.company"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
lintOptions …Run Code Online (Sandbox Code Playgroud) 我希望我的应用程序能够在不同的时间在编辑文本中显示不同的提示,所以我必须在每个时间以编程方式设置提示,如下所示。
editText.setHint("Hint 1");
Run Code Online (Sandbox Code Playgroud)
但问题是当我开始输入提示开始消失。我想每次都显示这个提示。如果我在 xml 中设置提示,它在输入时不会消失,但在我的情况下如何做到这一点。
当我尝试使用Spring Boot 2.1.2在tomcat中部署war时遇到此错误,我的tomcat版本是8.5.14,java是1.8.0_121。我将其部署在服务器上时出现以下错误,工作正常。
08-May-2019 05:54:33.459 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.14
08-May-2019 05:54:33.462 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /opt/apache-tomcat/webappsloop/LoopServer.war
08-May-2019 05:54:33.665 WARNING [localhost-startStop-1] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default version will be used.
08-May-2019 05:54:38.037 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during …Run Code Online (Sandbox Code Playgroud) 在我的Android应用程序中,我有一个使用MPAndroidChart的水平条形图。我的问题是我的条形图中有12个条形图,每个条形图表示从4月到3月的月份,但是我只能在x轴上看到替代月份的标签。少量的条,然后我可以看到x轴上的所有标签。我没有使用
xAxix.setLabelCount()
方法。那么为什么我看不到所有标签?如果我缩放了,那么我可以看到每个条的标签。我正在使用MPAndroidChart v3.0.1。上面的截图。请看这里,我只能看到'Apr,Jun,Aug,Oct,Dec,Feb'和所有其他月份未显示。如何查看其他所有月份。
下面是我的代码。
yVals1 = new ArrayList<BarEntry>();
xVals = new ArrayList<String>();
for (int i = 0; i < listChart.size(); i++){
BarEntry newBEntry = new BarEntry(i,listChart.get(i).getAmount());
xVals.add(listChart.get(i).getAltName());
yVals1.add(newBEntry);
}
BarDataSet set1;
set1 = new BarDataSet(yVals1, "");
set1.setColors(new int[] {Color.BLUE,Color.GREEN});
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
data.setValueTextSize(10f);
barChartIncExp.setData(data);
barChartIncExp.setDrawBarShadow(false);
barChartIncExp.setDrawValueAboveBar(true);
barChartIncExp.getDescription().setEnabled(false);
barChartIncExp.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
barChartIncExp.setPinchZoom(true);
barChartIncExp.setDrawGridBackground(false);
barChartIncExp.setHighlightFullBarEnabled(false);
barChartIncExp.setHighlightPerDragEnabled(false);
XAxis xAxis = barChartIncExp.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f); …Run Code Online (Sandbox Code Playgroud) 我正在使用spring security oauth2对我的android应用程序客户端进行身份验证。当客户端请求以Grant_type作为密码时,服务器将发出访问令牌和刷新令牌。如果访问令牌到期,我可以通过发送请求来发出新的访问令牌如果我的刷新令牌过期了,我该怎么办?我不想提示用户使用其凭据再次进行身份验证,那么是否有办法与新的访问令牌一起发行新的刷新令牌?或者是否有任何规定来发出具有无限有效性的刷新令牌,或者仅发送一次使用一次的刷新令牌并在每个refresh_token grant_type请求中刷新刷新令牌。以下是我的Spring Security oauth2的配置文件。
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd ">
<!-- This is default url to get a token from OAuth -->
<http pattern="/oauth/token" create-session="stateless"
authentication-manager-ref="clientAuthenticationManager"
xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
<anonymous enabled="false" />
<http-basic entry-point-ref="clientAuthenticationEntryPoint" />
<!-- include this only if you need to authenticate clients via request
parameters -->
<custom-filter ref="clientCredentialsTokenEndpointFilter"
after="BASIC_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<!-- This is …Run Code Online (Sandbox Code Playgroud) android ×7
spring ×2
spring-boot ×2
axis-labels ×1
bar-chart ×1
camera ×1
gradle ×1
java ×1
oauth-2.0 ×1
resttemplate ×1
tabs ×1
toggle ×1
togglebutton ×1
tomcat8 ×1