我正在尝试使用sharedpreferences来检查用户在开始使用应用程序之前是否已登录.我在用户登录时将用户名保存在shredpreferences中.
Login.java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Button btnLogin = (Button) findViewById(R.id.buttonlogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View adapt) {
EditText usernameEditText = (EditText) findViewById(R.id.EditUserName);
userName = usernameEditText.getText().toString();
EditText passwordEditText = (EditText) findViewById(R.id.EditPassword);
userPassword = passwordEditText.getText().toString();
if (userName.matches("") && userPassword.matches("")) {
toast("Please enter Username and Password");
return;
} else if (userName.matches("") || userName.equals("")) {
toast("Please enter Username");
return;
} else if (userPassword.matches("") || userPassword.equals("")) {
toast("Please enter Password");
return;
} else {
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor …Run Code Online (Sandbox Code Playgroud) 可能重复:
Android - ViewRootImpl $ CalledFromWrongThreadException
我试图从我的URL获取图像并在应用程序中显示但它抛出错误引起:android.view.ViewRootImpl $ CalledFromWrongThreadException:只有创建视图层次结构的原始线程才能触及其视图.以下是我的代码
码
package com.smartag.bird.dev;
public class MainActivity extends Activity {
static String ndefMsg = null;
static String ndefMsg1 = null;
NfcAdapter mNfcAdapter;
PendingIntent mNfcPendingIntent;
IntentFilter[] mNdefExchangeFilters;
static final String TAG = "Read Tag";
TextView mTitle;
private static ImageView imageView;
static String url = "http://sposter.smartag.my/images/chicken_soup.jpg";
private static Bitmap downloadBitmap;
private static BitmapDrawable bitmapDrawable;
private static boolean largerImg = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
mNfcPendingIntent …Run Code Online (Sandbox Code Playgroud) 我正在为我的系统使用apache.最近我收到了客户的投诉,说他们无法访问系统.我远程到我的服务器并检查我的Apache及其工作正常.我尝试启动localhost ant它也正常工作.我找不到任何问题,没有其他的去,而不是重新启动我的阿帕奇.重启后系统恢复正常.在对日志文件进行一些挖掘后,我发现了一些东西.
指定的网络名称不再可用.:AH00341:winnt_accept:异步AcceptEx失败.
我尝试谷歌,但无法找到解决方案.有没有人提前面对同样的问题并解决这个问题.以下是我的服务器详情:
Window Server 2008 R2标准
Apache 2.4
使用SSL连接
任何有关该问题的建议或参考链接都非常感谢.
我正在尝试将图像插入数据库.
CREATE TABLE ImageTable
(
Id int,
Name varchar(50) ,
Photo varbinary(max)
)
INSERT INTO ImageTable (Id, Name, Photo)
SELECT 10, 'John', BulkColumn
FROM Openrowset( Bulk 'C:\caldophilus.jpg', Single_Blob) as EmployeePicture
Run Code Online (Sandbox Code Playgroud)
它给我一个错误.
无法批量加载.文件"C:\ caldophilus.jpg"不存在.
请帮忙.
File mediaDir = new File("media");
if (!mediaDir.exists()){
mediaDir.createNewFile();
mediaDir.mkdir();
}
File f = new File("/data/data/com.test.image/files/media/Voucher.jpg");
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
fos.write(b);
fos.close();
Run Code Online (Sandbox Code Playgroud)
尝试在手机内存中写入文件但它抛出错误:java.io.IOException: Read-only file system
我是UICC和Secure Elements的新手,我尝试使用本教程(http://code.google.com/p/seek-for-android/wiki/UsingSmartCardAPI)来连接安全元素.当我运行应用程序时,它抛出一个java.lang.SecurityException:连接被拒绝!!! 请帮忙.谢谢
码
public void onCreate(Bundle savedInstanceState) {
final String LOG_TAG = "HelloSmartcard";
super.onCreate(savedInstanceState);
LinearLayout layout = new LinearLayout(this);
layout.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
Button button = new Button(this);
button.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
button.setText("Click Me");
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
Log.d(LOG_TAG, "Retrieve available readers...");
Reader[] readers = seService.getReaders();
if (readers.length < 1)
return;
Log.d(LOG_TAG, "Create Session from the first reader...");
Session session = readers[0].openSession();
Log.d(LOG_TAG,
"Create logical channel within the session...");
Channel channel = session.openLogicalChannel(new …Run Code Online (Sandbox Code Playgroud) 我创建了一个简单JTable的复选框,如下所示:
DefaultTableModel model = new DefaultTableModel();
jTable1.setModel(model);
model.addColumn("No:", no1);
model.addColumn("Remark", remark1);
model.addColumn("Color", colors1);
model.addColumn("Done");
TableColumn col1 = jTable1.getColumnModel().getColumn(0);
col1.setPreferredWidth(1);
TableColumn col4 = jTable1.getColumnModel().getColumn(3);
col4.setCellEditor(jTable1.getDefaultEditor(Boolean.class));
col4.setCellRenderer(jTable1.getDefaultRenderer(Boolean.class));
col4.setPreferredWidth(50);
jTable1.setShowGrid(true);
jTable1.setGridColor(Color.BLACK);
jTable1.setAutoCreateRowSorter(true);
Run Code Online (Sandbox Code Playgroud)
它工作正常,但如果我想为复选框添加动作监听器该怎么办.例如,当我选中我的复选框时,我需要弹出一条确认消息.
我试图从csv文件获取数据与以下数据.
Employee Name: Employee Id : Employee Type : Joining Date
Henry : 000123 : Permanent : 01/01/2011
Mathew : 111524 : Contract : 05/04/2011
Steven : 002544 : Permanent : 07/12/2010
Sophia : 015474 : : 29/02/2011
Rooney : 111303 : : 11/11/2010
Run Code Online (Sandbox Code Playgroud)
现在我想设置
我有2个cvs文件和2个格式文件,其中1表示永久类型,1表示合同类型.现在我想在没有提供数据时设置表中的值.例如,列"员工类型".我如何设置一个默认值,当我运行永久员工cvs'员工类型=永久'时,当我运行合同cvs'员工类型=合同'时.
BULK INSERT Employee_Table
FROM 'C:\Employee.csv'
WITH (
FIELDTERMINATOR ='';'',
FIRSTROW = 2,
ROWTERMINATOR = ''\n''
)
Run Code Online (Sandbox Code Playgroud) 我尝试创建Applescript以从.xfdf中提取值
XFDF
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<annots>
<square color="#FF0000" creationdate="D:20130828114843+05'30'" date="D:20130828114901+05'30'" flags="print" name="Xi6cOkAWgWHcAhpfBkR5A7" page="0" rect="347.7599999991828,1041.8400000004283,453.5999999989341,1056.9600000003927" subject="Rectangle" title="1 im, awltest7 (AWLTEST7.IM)">
<contents-richtext>
<body>
<p>Text Not Clear</p>
</body>
</contents-richtext>
<popup open="yes" page="0" rect="453.5999999989341,944.4600000003926,573.5999999989341,1056.9600000003927" />
</square>
<square color="#FF0000" creationdate="D:20130828114910+05'30'" date="D:20130828114919+05'30'" flags="print" name="ptmmBKtfoDEbVzirMgZLnY" page="0" rect="511.1999999987987,1092.960000000308,550.7999999987057,1123.9200000002352" subject="Rectangle" title="2 im, awltest7 (AWLTEST7.IM)">
<contents-richtext>
<body>
<p>Incorrect dimension</p>
</body>
</contents-richtext>
<popup open="yes" page="0" rect="550.7999999987057,1011.4200000002352,670.7999999987056,1123.9200000002352" />
</square>
<square color="#FF0000" creationdate="D:20130828114956+05'30'" date="D:20130828115004+05'30'" flags="print" name="8LaAl2Upx4LEaQptQKXoZx" page="0" rect="355.67999999916424,731.5200000011573,431.99999999898483,750.2400000011135" subject="Rectangle" title="3 im, awltest7 (AWLTEST7.IM)">
<contents-richtext>
<body>
<p>Incorrect Text</p>
</body> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码获取电话号码,
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
phoneImei = tm.getDeviceId();
phoneNo = tm.getLine1Number();
Run Code Online (Sandbox Code Playgroud)
但是,它返回null值.当我检查设置时,电话号码未知.我正在使用galaxy nexus.知道如何解决这个问题.