当我将应用程序部署到运行JRE 1.7的其他计算机时崩溃,我遇到了问题.当我在我的PC上运行NetBeans内部(甚至直接来自JAR文件)时,一切都很好.但是在另一台计算机上,它在执行期间在特定事件(按钮点击)时失败.
所以,我学会了使用log4j库进行日志记录.这给了我一些关于我的应用程序中的问题的信息,并且在我的计算机上再次完成了日志记录.但是当我将JAR文件部署到只运行JRE(Java 7 Update 17)的其他计算机时,我找不到任何日志文件的痕迹.
这是我的log4j.properties文件:
# Root logger option
log4j.rootLogger=INFO, file, stdout
# Direct log messages to a log file log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\logging.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}
%-5p %c{1}:%L - %m%n
# Direct log messages to stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}
%-5p %c{1}:%L - %m%n
Run Code Online (Sandbox Code Playgroud)
在我的计算机上,我可以在项目文件夹中看到logging.log文件.在某种程度上,一切都很完美.但是,在用户PC上,根本没有此文件的迹象.不在C:\(我认为它会在那里),而不是在C:\ Program Files(x86)\或其他任何地方.我已经完成了对硬盘的全面搜索,但没有任何回复.
该文件应存放在何处?我的属性设置正确吗?非常困惑...
谢谢!
我正在尝试使用服务帐户在Google日历上创建条目.我真的很接近这一点,但最后一行不起作用.500 Internal Service Error当我让这个运行时,我得到了一个.否则,程序运行无错误,无论价值多少.
该Calendar.php文件的内容可以发现在这里.在insert()我试图调用方法开始在该文件上的1455线.
<?php
function calendarize ($title, $desc, $ev_date, $cal_id) {
session_start();
/************************************************
Make an API request authenticated with a service
account.
************************************************/
set_include_path( '../google-api-php-client/src/');
require_once 'Google/Client.php';
require_once 'Google/Service/Calendar.php';
// (not real keys)
$client_id = '843319906820-jarm3f5ctbtjj9b7lp5qdcqal54p1he6.apps.googleusercontent.com';
$service_account_name = '843319906820-jarm3f5ctbtjj7b7lp5qdcqal54p1he6@developer.gserviceaccount.com';
$key_file_location = '../google-api-php-client/calendar-249226a7a27a.p12';
// echo pageHeader("Service Account Access");
if (!strlen($service_account_name) || !strlen($key_file_location))
echo missingServiceAccountDetailsWarning();
$client = new Google_Client();
$client->setApplicationName("xxxx Add Google Calendar Entries");
if (isset($_SESSION['service_token'])) {
$client->setAccessToken($_SESSION['service_token']);
}
$key = file_get_contents($key_file_location); …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的方法UIViewController,我试图更好地理解约束,自动布局和框架.视图控制器有两个子视图:两者都是UIViews,它们可以并排放置,也可以根据设备方向并排放置在顶部/底部.在每个UIView,都存在一个应该在其超级视图中居中的单个标签.
当设备旋转时, UIView s正确更新.我正在计算他们的框架尺寸和起源.但是,标签不会保持居中,并且不遵守故事板中定义的约束.
以下是显示问题的屏幕截图.如果我注释掉这个viewDidLayoutSubviews方法,那么标签就会完全居中(但随后是UIView s的大小不正确).我意识到我可以手动调整每个标签的框架,但我正在寻找一种方法,让他们在新调整大小的超级视图中尊重他们的约束.
这是代码:
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic) CGFloat spacer;
@end
@implementation ViewController
@synthesize topLeftView, bottomRightView, topLeftLabel, bottomRightLabel;
- (void)viewDidLoad {
[super viewDidLoad];
topLeftLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
bottomRightLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.spacer = 8.0f;
}
- (void)viewDidLayoutSubviews
{
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
[self setupTopLeftForLandscape];
[self setupBottomRightForLandscape];
} else {
[self setupTopLeftForPortrait];
[self setupBottomRightForPortrait];
}
}
- (void) setupTopLeftForPortrait {
CGRect frame = topLeftView.frame; …Run Code Online (Sandbox Code Playgroud) 我陷入了僵局.我正在使用Dagger 2进行依赖注入,但是当应用程序进入后台时,我正在失去状态.这是场景:应用程序启动并创建依赖项.只要应用程序停留在前台,所有功能都可以完美运行.但是,有一种情况是应用程序必须进入后台.当它返回时,存储在我注入的一个类中的值将丢失.
对于我没有自己依赖的注入类,一切似乎都恢复正常.但是,有一个注入类具有注入依赖项,而这是一个无法恢复的类.这是我如何设置它:
AppComponent.java
@Singleton
@Component(
modules = {
AppModule.class
}
)
public interface AppComponent {
SessionKeyExchangerService provideSessionKeyExchangerService();
AESCipherService provideCipherService();
void inject(LoginActivity loginActivity);
}
Run Code Online (Sandbox Code Playgroud)
AppModule.java
@Module
public class AppModule {
@Provides @Singleton
AESCipherService provideCipherService() {
return new AESCipherService();
}
@Provides @Singleton
SessionKeyExchangerService provideSessionKeyExchangerService(AESCipherService service) {
return new SessionKeyExchangerService(service);
}
}
Run Code Online (Sandbox Code Playgroud)
然后,当我去注入这些依赖项时,我这样做:
LoginActivity.java
@Inject
SessionKeyExchangerService sessionKeyExchangerService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Injector.INSTANCE.getAppComponent().inject(this);
if (savedInstanceState != null) {
sessionKeyExchangerService = savedInstanceState.getParcelable(SESSION_KEY_PARCEL);
Log.d(Constants.TAG, "session key retrieved in on create: " …Run Code Online (Sandbox Code Playgroud) 作为漫长而肮脏的故事的一部分,其最终目标只是安装GMP以与Windows中的code :: blocks一起使用,我正在尝试配置gmp.我使用以下命令执行此操作:
./configure --prefix = $ {gmp_install}
一切都开始得很好.几分钟后,一点点进展,一切都停止了,我得到这个消息:
configure:error:$ PATH或/ usr5bin中没有可用的M4
我甚至不知道M4是什么,但我发现它是某种宏处理器.所以我下载它,并将文件夹添加到我的Path变量.然后我再次启动配置,但结果相同.
我需要做些什么让M4让它运转起来吗?我真的很茫然.谢谢你的帮助.
我正在努力解决与a有关的一系列令人费解的事件Fragment.我正在尝试向一个片段添加一个片段Activity,然后在片段内调用一个方法来更新一些文本.但是,我发现的是该方法在 onCreateView()完成之前在片段中处理,这使我留下了一个空View对象,并且我的方法失败了.这是Activity代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_entry_details);
fragmentManager = getSupportFragmentManager();
titleBarFragment = new TitleBarVerticalFragment();
fragmentTransaction = fragmentManager.beginTransaction ();
fragmentTransaction.add(R.id.log_entry_title_frame, titleBarFragment);
fragmentTransaction.commit();
titleBarFragment.updateTitleBar("Edit Log Entry", 20, false);
}
Run Code Online (Sandbox Code Playgroud)
看起来很简单.这是TitleBarVerticalFragment类:
public class TitleBarVerticalFragment extends TitleBarFragment {
@Inject SharedVisualElements sharedVisualElements;
View view;
TextView titleLabel;
public TitleBarVerticalFragment() {
// add this line for any class that want to use any of the singleton objects
Injector.INSTANCE.getAppComponent().inject(this);
}
@Override
public View …Run Code Online (Sandbox Code Playgroud) 我有一个返回指针的函数:
static void*find_fit(size_t asize);
我想在gdb中设置一个断点,但是当我输入这个函数名时,我得到以下错误之一:
break*find_fit函数"*find_fit"未定义
要么
break find_fit函数"find_fit"未定义
我可以轻松地在返回指针以外的函数的函数上设置断点,但是当函数确实返回指针时,gdb似乎不想在它上面打破.
有谁看到发生了什么?谢谢!
我正在尝试将一些AsyncTask类拆分为公共(单独)函数,这样我就不必重写这么多代码了.我几乎拥有它,除了一个非常重要的方面.AsyncTask函数通过对服务器进行php调用来编译ArrayList.完成此列表后,我需要更新主UI线程上的微调器.我在这里找到了一个非常好的答案,但是我在使它工作时遇到了一些困难.
这是我所拥有的缩小版本:(请注意,此时,我要做的就是拨打一条Toast消息来证明往返行程正常)
这是呼唤Activity:
public class MyActivity extends Activity implements OnTaskCompleted {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sg_list = new ArrayList<String>();
new GetSuperGroups(UpdateAffiliationsPreferences.this, context, "Retrieving Group List...").execute();
}
public void onTaskCompleted(ArrayList<String> list) {
Toast.makeText(getApplicationContext(), "hello from async", Toast.LENGTH_SHORT).show();
}
}
Run Code Online (Sandbox Code Playgroud)
这是界面:
public interface OnTaskCompleted {
void onTaskCompleted(ArrayList<String> list);
}
Run Code Online (Sandbox Code Playgroud)
最后,这是AsyncTask.请注意,它是一个Public类:
public class GetSuperGroups extends AsyncTask<String, String, ArrayList<String>> {
private Activity activity;
private Context context;
private String progressMsg;
private ProgressDialog …Run Code Online (Sandbox Code Playgroud) 我正在学习多窗格应用程序,并且正在运行Master/Detail Flow应用程序,该应用程序在您创建新项目时由Android Studio设置(并选择此选项).根据创建的Google代码中的注释,应用程序应以多窗格模式显示,以用于具有大屏幕布局的设备.我遇到的问题是无论我使用什么AVD,我只能获得一个窗格.首先,这是主要活动的onCreate方法.请注意,此代码直接来自Google(不是我的代码):
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
if (findViewById(R.id.item_detail_container) != null) {
// The detail container view will be present only in the
// large-screen layouts (res/values-large and
// res/values-sw600dp). If this view is present, then the
// activity should be in two-pane mode.
mTwoPane = true;
// In two-pane mode, list items should be given the
// 'activated' state when touched.
((ItemListFragment) getFragmentManager()
.findFragmentById(R.id.item_list))
.setActivateOnItemClick(true);
}
// TODO: If exposing deep links into your app, handle …Run Code Online (Sandbox Code Playgroud) 我无法验证用户日历上是否已存在某个事件.我需要检查这个以确定是否应该添加它,以便我不创建重复的日历条目.现在,我每次运行代码时都会创建一个重复的条目.
首先,这是我创建日历条目的方式:
+ (NSString *) addEventToCalenderWithDate : (NSDate *) eventDate
eventTitle : (NSString *) eventTitle
eventLocation : (NSString *) eventLocation
allDayEvent : (BOOL) isAllDay
{
EKEventStore *store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (!granted) {
returnValue = @"calendar error";
}
else if ([self eventExists:dateAndTime eventTitle:eventTitle allDayEvent:isAllDay]) {
returnValue = @"duplicate";
}
else {
EKEvent *event = [EKEvent eventWithEventStore:store];
event.title = eventTitle;
event.startDate = dateAndTime;
if (eventTimeString == (id)[NSNull null] || eventTimeString.length == 0 || …Run Code Online (Sandbox Code Playgroud) android ×4
ios ×2
objective-c ×2
autolayout ×1
breakpoints ×1
codeblocks ×1
dagger-2 ×1
ekeventstore ×1
gdb ×1
gmp ×1
java ×1
log4j ×1
logging ×1
m4 ×1
php ×1
state ×1
uiview ×1
windows ×1