我最近在Beta版频道将我的Android Studio更新为1.3,我注意到Use in process-build编译器 - > Gradle设置菜单已经消失了.那么我想知道如何在考虑一个已知问题的情况下调试我的Robolectric测试,如在Android Studio中运行Robolectric测试时的如何调试中所述?和http://www.culmination.org/2014/03/debugging-during-robolectric-test-execution-in-android-studio/
我收到java.net.SocketException "Socket closed"错误,我不知道如何禁用Use in process-build.
我正在使用Jersey实现Restful Web Service.我想将index.jsp显示为欢迎页面.
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Rest Page</title>
</head>
<body>
<h1>Rest is working!</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我在web.xml中使用此代码时工作正常:
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/whatever/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
问题是用户模式是这样的:
<url-pattern>/*</url-pattern>
Run Code Online (Sandbox Code Playgroud)
一切正常,除了欢迎页面.我感谢任何帮助.
我是iOS开发的新手.我有这个故事板:

当我点击Page 1 Bar按钮项目 - >使用后退按钮转到第2页(使用push segue)
基本上通过单击后退按钮 - >返回到第1页
如你所见,我在第2页中有一个保存栏按钮,我的问题是,当我点击此按钮时,我想将数据保存在数据库中并返回到Page1.
你能帮帮我怎样才能回到第一页?
- (void)save:(id)sender
{
NSLog(@"Save");
// SaveDataToDb
if(Data successfully saved in database)
//Go Back to Page 1 ???
else
// Proper error message
}
Run Code Online (Sandbox Code Playgroud) 所以我将代码更改为调用广播接收器,而不是调用主要活动
Intent notificationIntent = new Intent(context, com.plugin.statusNotificationForGCM.statusNotificationForGCMReceiver.class);
notificationIntent.putExtra(NOTIF_RESPOND, runThis);
notificationIntent.setAction(Intent.ACTION_VIEW);
notificationIntent = notificationIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
//contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
contentIntent = PendingIntent.getBroadcast(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Run Code Online (Sandbox Code Playgroud)
问题是我在接收器中添加了它,但认为它没有运行。单击通知后看不到标签并登录控制台
public class statusNotificationForGCMReceiver extends BroadcastReceiver {
private static final String TAG = "statusNOTIFICATIONReceiver";
@Override
public final void onReceive(Context context, Intent intent) {
Log.v(TAG,"ASDFSJD FASDF ASDPFJA SDFPAUS DFPAS DFASDF");
}
}
Run Code Online (Sandbox Code Playgroud)
我有什么想念的吗?我是否必须在清单文件中添加一些内容?
谢谢
我的android应用程序连接使用Web服务执行外部数据库.在一种情况下,我有巨大的数据的数量,并且我得到了内存溢出异常:
09-09 20:05:59.441: ERROR/dalvikvm(4688): Out of memory: Heap Size=15751KB, Allocated=14962KB, Bitmap Size=687KB
09-09 20:05:59.451: WARN/dalvikvm(4688): threadid=23: thread exiting with uncaught exception (group=0x4001e390)
09-09 20:05:59.462: ERROR/AndroidRuntime(4688): Uncaught handler: thread AsyncTask #5 exiting due to uncaught exception
09-09 20:05:59.731: ERROR/AndroidRuntime(4688): java.lang.RuntimeException: An error occured while executing doInBackground()
09-09 20:05:59.731: ERROR/AndroidRuntime(4688): at android.os.AsyncTask$3.done(AsyncTask.java:200)
09-09 20:05:59.731: ERROR/AndroidRuntime(4688): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
09-09 20:05:59.731: ERROR/AndroidRuntime(4688): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
09-09 20:05:59.731: ERROR/AndroidRuntime(4688): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
09-09 20:05:59.731: ERROR/AndroidRuntime(4688): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-09 20:05:59.731: ERROR/AndroidRuntime(4688): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
09-09 …Run Code Online (Sandbox Code Playgroud) 我在故事板中有两个视图控制器.我以编程方式成功地从第一个导航到第二个:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
YourViewController *yourViewController = (YourViewController *)[storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerID"];
[self.navigationController pushViewController:yourViewController animated:YES];
Run Code Online (Sandbox Code Playgroud)
我想使用我的customSegue导航到其他页面,而不是pushViewController使用界面构建器.
这是我可以轻松使用界面构建器的自定义Segue:
@interface LeftToRightSegue : UIStoryboardSegue
Run Code Online (Sandbox Code Playgroud)
怎么样以编程方式呢?
我尝试在 TeamCity 中为 Android 项目执行 Gradle 任务,但失败并出现以下错误:
java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
Run Code Online (Sandbox Code Playgroud)
我搜索了一下并找到了以下建议: Android SDK location vs Build Server, how to set it?
setting ANDROID_HOME variable inside TeamCity server file - buildAgent.properties
Run Code Online (Sandbox Code Playgroud)
我在 TeamCity/BuidAgent/conf 下打开 buildAgent.properties,并添加以下内容:
sdk.dir=/Users/ali/Library/Android/sdk
Run Code Online (Sandbox Code Playgroud)
但它仍然失败并出现相同的错误消息。你知道我错过了什么吗?
我是iOS开发的新手.我的Storyboard中有这个ViewController(包括一个UIDatePicker和一个条形按钮):

我跟着Data Cell来调用我的DatePicker.当用户点击页面中的按钮时,PickerDate会弹出导航栏上的完成栏按钮:

问题是它只显示当前日期default.从Properties中设置时没有任何变化:

你知道我怎么解决它?(通过setting up the properties或以编程方式).
我是iOS新手.我创建了JSON NSDictionary这样的:
NSArray *keys = [NSArray arrayWithObjects:@"User", @"Password", nil];
NSArray *objects = [NSArray arrayWithObjects:@"Ali", @"2020", nil];
NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
Run Code Online (Sandbox Code Playgroud)
然后我可以NSString通过两种机制将其转换为:
1)
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDictionary options:0 error:&error];
NSString *jsonString = nil;
if (! jsonData) {
NSLog(@"Got an error: %@", error);
} else {
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
Run Code Online (Sandbox Code Playgroud)
2)
NSString *jsonString = [jsonDictionary JSONRepresentation];
Run Code Online (Sandbox Code Playgroud)
在第二种方式,我得到这个warning:
Instance method '-JSONRepresentation' not found (return type defaults to 'id')
Run Code Online (Sandbox Code Playgroud)
但是当我运行项目时,两种机制都可以正常工作: …
有没有办法获取另一个Android应用程序的图标的资源ID?(例如com.android.systemui.R.drawable.ic_xxx)
我试过context.getApplicationInfo().icon但它返回了一个长整数.这可能吗?
谢谢