我MainActicity 开始RefreshService用Intent具有boolean所谓的多余isNextWeek.
我RefreshService做了一个在用户点击它时Notification启动我MainActivity的.
这看起来像这样:
Log.d("Refresh", "RefreshService got: isNextWeek: " + String.valueOf(isNextWeek));
Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.putExtra(MainActivity.IS_NEXT_WEEK, isNextWeek);
Log.d("Refresh", "RefreshService put in Intent: isNextWeek: " + String.valueOf(notificationIntent.getBooleanExtra(MainActivity.IS_NEXT_WEEK,false)));
pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
builder = new NotificationCompat.Builder(this).setContentTitle("Title").setContentText("ContentText").setSmallIcon(R.drawable.ic_notification).setContentIntent(pendingIntent);
notification = builder.build();
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(NOTIFICATION_REFRESH, notification);
Run Code Online (Sandbox Code Playgroud)
你可以看到notificationIntent应该有boolean额外IS_NEXT_WEEK的值,isNextWeek其中放入了PendingIntent.
当我现在点击这个时, …
android android-intent android-service android-pendingintent
错误:
Gradle: Execution failed for task ':vertretungsplan:dexDebug'.
> Failed to run command:
P:\Android-Studio\sdk\build-tools\18.0.1\dx.bat --dex --output P:\Projekte\VertretungsplanProject\vertretungsplan\build\libs\vertretungsplan-debug.dex P:\Projekte\VertretungsplanProject\vertretungsplan\build\classes\debug P:\Projekte\VertretungsplanProject\vertretungsplan\build\dependency-cache\debug P:\Android-Studio\sdk\extras\android\m2repository\com\android\support\support-v4\18.0.0\support-v4-18.0.0.jar P:\Projekte\VertretungsplanProject\vertretungsplan\libs\commons-io-2.4.jar P:\Projekte\VertretungsplanProject\vertretungsplan\build\exploded-bundles\VertretungsplanProjectLibrariesActionbarsherlockUnspecified.aar\classes.jar
Error Code:
2
Output:
trouble processing:
bad class file magic (cafebabe) or version (0033.0000)
...while parsing de/MayerhoferSimon/Vertretungsplan/LoginActivity$2.class
...while processing de/MayerhoferSimon/Vertretungsplan/LoginActivity$2.class
trouble processing:
bad class file magic (cafebabe) or version (0033.0000)
...while parsing de/MayerhoferSimon/Vertretungsplan/MainActivity$1.class
...while processing de/MayerhoferSimon/Vertretungsplan/MainActivity$1.class
trouble processing:
bad class file magic (cafebabe) or version (0033.0000)
...while parsing de/MayerhoferSimon/Vertretungsplan/YQL/YqlVplanParser.class
...while processing de/MayerhoferSimon/Vertretungsplan/YQL/YqlVplanParser.class
3 warnings
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.util.DexException: Multiple …Run Code Online (Sandbox Code Playgroud) 无论我在哪里,FrameLayout似乎都被用作FragmentContainer.为什么FrameLayout总能看到Fragments?
当我在主活动中声明并初始化变量为静态并且活动被销毁时.我还可以访问变量的内容吗?
例如,要始终访问我存储到此变量的AsyncTask?我想要的是能够在方向改变后访问它.
我有点困惑,因为我不知道如何解释这个教程:http://developer.android.com/training/basics/data-storage/databases.html#DbHelper
我的代码到现在看起来像这样:
public final class DatabaseContract {
// To prevent someone from accidentally instantiating the contract class,
// give it an empty constructor.
public DatabaseContract() {}
public static abstract class Table1 implements BaseColumns {
public static final String TABLE_NAME = "nameOfTable";
public static final String COLUMN_NAME_COL1 = "column1";
public static final String COLUMN_NAME_COL2 = "column2";
public static final String COLUMN_NAME_COL3 = "column3";
}
public class DatabaseHelper extends SQLiteOpenHelper {
// If you change the database schema, you …Run Code Online (Sandbox Code Playgroud) 当用户按下Send "Button 1"(向下滚动以查看应用程序的构造)时,将Notification创建一个新的RefreshService.如果用户按下此通知,则MainActivity实例启动并接收String具有Button 1超过该值的值Intent.
显示该值.
当用户现在按下时,Send "Button 2"将Notification创建一个新的RefreshService.如果用户按下此通知,则会MainActivity启动一个实例,并接收一个ALSO值超过该值的ALSO.String Button 1Intent
所以你可以猜测,通常应该有价值Button 2.
当用户按下的第一个按钮时,Send "Button 2"总会Button 2发送.
获得第二个按钮值的唯一解决方案是重新启动手机并先按下第二个按钮.即使强行关闭也行不通.
我知道我也可以用另一种方式更改UI.但是我需要在应用程序中使用这种方法,我需要用另一个重新启动'MainActivity',Intent因此方法应该是相同的.
一个Activity叫MainActivity
一个IntentService叫RefreshService
主要活动
public class MainActivity extends Activity implements View.OnClickListener {
public static final String RECEIVED = "received"; …Run Code Online (Sandbox Code Playgroud) android android-intent android-notifications intentservice android-activity
我正在尝试创建一个小部件.我就像这里描述的那样:https://stackoverflow.com/a/6093753/2180161
它部分工作,但我有一个非常奇怪的错误.我做了一个截屏视频,所以更容易理解我的意思:http: //c.maysi.de/c6H9
如您所见,有一些项目是随机添加的.(RemoteViews已添加到另一个RemoteViews对象)
当我调整窗口小部件时,会发生同样的情况.
我在日志中打印的内容与预期的一样.没有错误的数据.滚动时也没有新的日志条目.
这是我的代码:
RemoteViewsFactory:
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class MyWidgetViewsFactory implements RemoteViewsService.RemoteViewsFactory {
private static ArrayList<Item> items = new ArrayList<>();
private static int itemnr = 0;
private static int subitemnr = 0;
private int appWidgetId;
private Context context;
public MyWidgetViewsFactory(Context context, Intent intent) {
this.context = context;
appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
//Some random data to display
for (int i = …Run Code Online (Sandbox Code Playgroud) android listview android-widget android-listview android-appwidget
每次启动Android Studio时都会出现以下错误:
Gradle'VertretungsplanProject'项目刷新失败:无法使用Gradle发行版" http://services.gradle.org/distributions/gradle-1.6-bin.zip " 获取"IdeaProject"类型的模型.配置项目':Vertretungsplan'时出现问题.配置项目':Vertretungsplan'时出现问题.无法通知项目评估监听器.配置项目':libraries:actionbarsherlock'时出现问题.无法通知项目评估监听器.无法规范化文件'P:\ Projekte\VertretungsplanProject\libraries\actionbarsherlock:Vertretungsplan\libs\android-support-v4.jar'的路径.文件名,目录名或卷标的语法错误
我的项目看起来像这样:

Gradle设置:

build.gradle of :Vertretungsplan:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/commons-io-2.4.jar')
compile project(':libraries:actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
}
Run Code Online (Sandbox Code Playgroud)
build.gradle :VertretungsplanProject为空.
build.gradle :actionbarsherlock:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile files(':Vertretungsplan/libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion …Run Code Online (Sandbox Code Playgroud) 我想检查一个字符串是否只是mytches以下格式:
"00-00"
Run Code Online (Sandbox Code Playgroud)
字符串中应该没有空格,破折号前面只有2个数字,破折号后面只有2个数字.
最好的方法是什么?
我尝试了以下方法:
http://codepen.io/anon/pen/YXePBY
<div>lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet</div>
div {
width: 280px;
height: 280px;
background: #1e90ff;
-webkit-clip-path: polygon(0 0, 78% 0, 93% 99%, 0% 100%);
clip-path: polygon(0 0, 78% 0, 93% 99%, 0% 100%);
padding: 15px
}
/* Center the demo …Run Code Online (Sandbox Code Playgroud)