Iam 从预定服务中调用Asynctask每10分钟就会运行一次.
运行Service时,Progress对话框从OnpreExecute获取Exception .
错误:
FATAL EXCEPTION: main
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
at android.view.ViewRootImpl.setView(ViewRootImpl.java:594)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:286)
Run Code Online (Sandbox Code Playgroud)
编辑1: 警报管理器每5分钟调用一次服务
/*Alarm manager Service for From Server*/
private void setServerFetch() {
// for to Server to GPS PING
Intent myIntent1 = new Intent(LoginPage.this, AlarmService.class);
pendingintent1 = PendingIntent.getService(LoginPage.this, 1111, myIntent1, 0);
AlarmManager alarmManager5 = (AlarmManager) getSystemService(ALARM_SERVICE);
Calendar calendar1 = Calendar.getInstance();
calendar1.setTimeInMillis(System.currentTimeMillis());
calendar1.add(Calendar.SECOND, 1);
alarmManager5.set(AlarmManager.RTC_WAKEUP, …Run Code Online (Sandbox Code Playgroud) service android progressdialog android-asynctask android-pendingintent
我希望我的textview和imageview像上面提到的图像.
1.我想使用约束布局在单行中水平设置Textview和Imageview.
2.Textview不会到达Imageview的中间(中间).(左右位置)
3.Also布局比重,没有努力使TextView的中心,由于Cosntraint布局
帮助我实现这一目标.
提前致谢.
<android.support.v7.widget.CardView
android:id="@+id/cv2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:cardCornerRadius="4dp"
app:layout_constraintTop_toBottomOf="@+id/cv1">
<android.support.constraint.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Hero"
android:textColor="@color/colorPrimary"
android:textSize="16dp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/display_pic"
/>
<ImageView
android:id="@+id/display_pic"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentEnd="true"
android:layout_margin="16dp"
android:adjustViewBounds="false"
android:scaleType="centerCrop"
app:layout_constraintLeft_toLeftOf="@+id/title1"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:color/holo_red_light" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud) 我在我的Android应用程序中使用谷歌加登录其工作正常.
同时从任何其他意图单击注销按钮显示空指针异常.
也点击登录按钮直接进入我的下一页.不在登录页面.
但从演示应用程序注销其工作正常.
我已搜索到相关答案,未找到任何解决方案仍然保持不变.
帮我解决一下
我已经引用了2个链接但是从下一个意图中退出仍然显示Null指针Exception.
我的退出代码:
public void googlePlusLogout()
{
if (mGoogleApiClient.isConnected())
{
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
mGoogleApiClient.disconnect();
mGoogleApiClient.connect();
updateProfile(false);
}
}
Run Code Online (Sandbox Code Playgroud)
这里从其他意图调用方法来登录类
otherintent.java
session.logoutUser();// here i am clearing the shared pref
sign_in Signinclass = new sign_in();
Signinclass.googlePlusLogout();
finish();
Run Code Online (Sandbox Code Playgroud)
这是我的演示代码,它的工作正常,我在我的应用程序登录中使用的相同代码工作正常,但是从其他页面调用的Logout无效.显示空指针异常.
AndroidGooglePlusExample .java
public class AndroidGooglePlusExample extends Activity implements OnClickListener, ConnectionCallbacks, OnConnectionFailedListener {
private static final int RC_SIGN_IN = 0;
// Google client to communicate with Google
private GoogleApiClient mGoogleApiClient;
private boolean mIntentInProgress;
private boolean signedInUser;
private ConnectionResult mConnectionResult;
private …Run Code Online (Sandbox Code Playgroud) 我在Android应用程序中使用导航抽屉,工作正常.
我想补充一些动画的打开和关闭的抽屉式导航栏.
动画:
1.Opening-Navigation Drawer显示箭头,隐藏汉堡包.
2.Closing-Again显示汉堡包,隐藏箭头.
打开和关闭它应该是旋转.我尝试了一些不工作的代码.
请有人帮我这样做.
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我尝试了这个, 链接我提到
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
//for Navigation Bar
DrawerLayout drawerLayout;
ListView listView;
String[] drawerlist;
ActionBarDrawerToggle drawerListener;
private MyAdapter4 myAdapter4;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.alerts);
//navigation initialize
drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
listView = (ListView) findViewById(R.id.drawerList);
drawerlist …Run Code Online (Sandbox Code Playgroud) 我把Signatureview里面的 Android Scrollview。
但是在 上写东西时SignatureView,上下滚动我无法写出我的标志。
如何禁用Scrollview何时SignatureView被触摸
签名文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="false"
android:paddingBottom="30dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:scrollbars="none">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.kyanogen.signatureview.SignatureView
xmlns:sign="http://schemas.android.com/apk/res-auto"
android:id="@+id/signature_view"
android:layout_width="match_parent"
android:layout_height="100dp"
android:minHeight="250dp"
android:layout_weight="1"
sign:penSize="5dp"
sign:backgroundColor="#ffffff"
sign:penColor="#000000"
sign:enableSignature="true"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/clearSignButton"
android:layout_weight="1"
android:text="clear"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/saveSignButton"
android:layout_weight="1"
android:text="save"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</Scrolview>
Run Code Online (Sandbox Code Playgroud)
主程序
package com.example.parsaniahardik.signaturedemo;
import android.graphics.Bitmap;
import …Run Code Online (Sandbox Code Playgroud) 1.without proguard 一切正常。在启用 Proguard 时,所有头部和身体模型都变得模糊不清。
2.Retrofit2 无法通过模型对象传递数据。
D/OkHttp: Content-Type: application/json
Content-Length: 80
{"a":{"a":"123","b":"***","c":"","d":"Data","f":"1.0"},"b":{"a":""}}
--> END POST (80-byte body)
Run Code Online (Sandbox Code Playgroud)
下面提到的 Proguard 规则已经添加到我的代码中,但仍然遇到同样的问题,请帮助我解决这个问题。
# Retrofit
-dontwarn retrofit2.**
-dontwarn org.codehaus.mojo.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations
-keepattributes EnclosingMethod
-keepclasseswithmembers class * {
@retrofit2.* <methods>;
}
-keepclasseswithmembers interface * {
@retrofit2.* <methods>;
}
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform …Run Code Online (Sandbox Code Playgroud) 我ActionBar.TabListener在My Tab Fragment中实现了.
我更新了API 22,更新它展示后ActionBar.TabListener和ActionBarActivity 被弃用.
像我在我的代码中使用的那样
public class Tabview_Landing extends ActionBarActivity implements ActionBar.TabListener
{
}
Run Code Online (Sandbox Code Playgroud)
链接帮助我解决这个问题.
我在我的 android 应用程序中使用 facebook 登录。
1.它获取并显示用户名很好,但用户的电子邮件ID显示为空。
2.how to get user email id,谁帮我解决这个问题,提前致谢。
主活动.java
public class MainActivity extends FragmentActivity {
private LoginButton loginBtn;
private Button postImageBtn;
private Button updateStatusBtn;
private TextView userName;
private UiLifecycleHelper uiHelper;
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions","email");
private static String message = "Sample status posted from android app";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(this, statusCallback);
uiHelper.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userName = (TextView) findViewById(R.id.user_name);
loginBtn = (LoginButton) findViewById(R.id.fb_login_button);
loginBtn.setBackgroundResource(R.drawable.fb);
loginBtn.setCompoundDrawablesWithIntrinsicBounds(0, 0, …Run Code Online (Sandbox Code Playgroud) 我曾经使用过两种在android活动中创建实例的方法.哪一种方法更好,方法1或方法2.
方法1:
//Global instance
Button btn;
//Inside Oncreate
btn = (Button)findViewById(R.id.btn);
//some other Place
btn.setVisibility(View.VISIBLE);
btn.setText("Hai");
Run Code Online (Sandbox Code Playgroud)
方法2: //在需要它的地方
((Button)findViewById(R.id.btn)).setVisibility(View.VISIBLE);
((Button)findViewById(R.id.btn)).setText("Hai");
Run Code Online (Sandbox Code Playgroud)
不需要Butterknife和Data Binding.
1.当尝试使用tablename作为参数使用方法访问数据时,使用android中的Room Library获取下面提到的错误.
- >查询有问题:ERROR] SQL错误或缺少数据库(没有这样的表:表名)
MainActivity.class
userData1= userSampleDatabase.daoAccessForUser().getItembyIdvalue("UserData","1");
Run Code Online (Sandbox Code Playgroud)
DaoAccessForUser.class
@Query("select * from 'tableName' where id = :id")
List<UserData> getItembyIdvalue(String tableName,String id);
Run Code Online (Sandbox Code Playgroud)
提前致谢.
android ×10
android-architecture-components ×1
android-room ×1
android-tabs ×1
butterknife ×1
drawertoggle ×1
facebook ×1
google-plus ×1
retrofit ×1
retrofit2 ×1
service ×1
signature ×1