我做了一个聊天应用程序.我想在我的应用程序中添加照片/文件共享概念,与WhatsApp相同.我已经使用了Xmpp/Openfire当前的应用程序和当前我正在使用此功能进行照片共享,但它并非全部可靠:
public void sendFile(final String path, final String receiver) {
Thread thread = new Thread() {
public void run() {
ServiceDiscoveryManager sdm = ServiceDiscoveryManager
.getInstanceFor(connection);
if (sdm == null)
sdm = new ServiceDiscoveryManager(connection);
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
// Create the file transfer manager
FileTransferManager manager = new FileTransferManager(
connection);
FileTransferNegotiator.setServiceEnabled(connection, true);
// Create the outgoing file transfer
OutgoingFileTransfer transfer = manager
.createOutgoingFileTransfer(receiver + "/Smack");
System.out.println("Receiver of the file is "+receiver+"/smack");
Log.i("transfere file", "outgoingfiletransfer is created");
try {
OutgoingFileTransfer.setResponseTimeout(30000); …Run Code Online (Sandbox Code Playgroud) 在我的聊天应用程序中,我希望实现一种功能,即每当用户已经登录并且他/她想要使用相同的用户名和密码再次在其他设备中登录时,它应该向用户返回一条消息 - "你是已登录其他地方"
我只知道这种方法来检查登录状态 -
connection.isConnected();
Run Code Online (Sandbox Code Playgroud)
但这不会成为我的目的.
在我的应用程序中,在按钮上单击我创建一个Toast as -
Toast.makeText(context,"Please Enter Username",Toast.LENGTH_SHORT).show();
Run Code Online (Sandbox Code Playgroud)
但是当有人点击按钮5-6次并关闭应用程序,或者进入另一个屏幕时,它仍然会在另一个屏幕上继续显示Toast一段时间.我见过很多相同的解决方案.
我试过了 -
toast = Toast.makeText(LoginActivity.this, message, Toast.LENGTH_SHORT);
toast.show();
Run Code Online (Sandbox Code Playgroud)
并取消了这个吐司 -
onPause(){
if(toast!=null){
toast.cancel();
}
Run Code Online (Sandbox Code Playgroud)
同样的 onDestroy()
我希望当任何人点击按钮5-6次并离开应用程序或该活动时,toast消息应该消失.或建议任何替代解决方案.
我在android中开发了一个聊天应用程序,我想在我的应用程序中添加Emoctions功能.我已遍历以下链接:
但是之间没有找到任何好的解决方案.
请指导我一个很好的超链接或解决方案.
场景:一个人可以从当前的集合中选择任何一个集合,它也应该在接收端收到.
我想用我的应用程序配置proguard.但在这样做时,我收到以下问题:
[2013-09-24 12:27:46 - DemoProguard] Proguard returned with error code 1. See console
[2013-09-24 12:27:46 - DemoProguard] Warning: com.google.android.gms.internal.bn$b: can't find referenced method 'android.view.Display getDisplay()' in class android.view.View
[2013-09-24 12:27:46 - DemoProguard] Warning: com.google.android.gms.internal.bn$b: can't find referenced method 'void removeOnGlobalLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener)' in class android.view.ViewTreeObserver
[2013-09-24 12:27:46 - DemoProguard] You should check if you need to specify additional program jars.
[2013-09-24 12:27:46 - DemoProguard] Warning: there were 2 unresolved references to program class members.
[2013-09-24 12:27:46 - DemoProguard] Your input classes appear …Run Code Online (Sandbox Code Playgroud) 我想在Android通知栏中显示大图片样式图片.但是我遇到了问题 - >当我使用以下代码在通知栏中设置图像时:
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title)
.setContentText(message)
.setOngoing(false)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(bitmap))
.setPriority(Notification.PRIORITY_HIGH)
//.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setContentIntent(resultPendingIntent);
// mId allows you to update the notification later on.
mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
NotificationManager mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0 , mBuilder.build());
Run Code Online (Sandbox Code Playgroud)
它始终从左右角落裁剪.我不想使用远程视图.任何人都可以告诉我可以放在通知栏中的图像的大小和分辨率,不应该被裁剪.
谢谢
我需要从字符串中提取一个4位数字:
例如"您登录的otp是7832.此代码将于12:43:09 PM到期"来自Android中的短信
我想提取7832或字符串中的任何4位数代码.我确保字符串中只有一个4位数代码.
请帮我.我试图使用如下模式:
str.matches(".*\\\\d+.*");
Run Code Online (Sandbox Code Playgroud)
但是我无法理解正则表达式.
我有一个带复选框的列表视图,我希望当用户选中任何复选框并关闭应用程序,并再次打开应用程序时,应选择相同的复选框.即我必须使用sharedpref方法保存listview项的复选框的状态.在这里我实现了相同的,但没有得到理想的结果,我已经尝试了很多请帮助我.
MyCustomAdapter.java
public class MyCustomBaseAdapter extends BaseAdapter implements OnCheckedChangeListener {
private static ArrayList<SearchResults> searchArrayList;
ViewHolder holder;
private LayoutInflater mInflater;
Editor editor;
Context context;
public MyCustomBaseAdapter(Context context, ArrayList<SearchResults> results) {
searchArrayList = results;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return searchArrayList.size();
}
public Object getItem(int position) {
return searchArrayList.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
SharedPreferences sharedPrefs = context.getSharedPreferences("sharedPrefs", Context.MODE_PRIVATE);
if (convertView == null) {
convertView = …Run Code Online (Sandbox Code Playgroud) 我正在使用Google Maps Api V2制作演示应用.
我添加了一个简单的标记,并使其可拖动
这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.demo_v2);
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
googleMap.setOnMapClickListener(this);
googleMap.setOnMarkerDragListener(this);
googleMap.setOnMapLongClickListener(this);
Run Code Online (Sandbox Code Playgroud)
}
现在我希望当用户点击标记时地址出现.
简单的问题是:想要在API v2中从Lat Long获取地址(名称)
我想在我的onActivityResult方法中检测人是否已发送电子邮件或按下后退按钮或将其丢弃.我怎么能这样做.
我是这样做的
String[] reciepients = result.toArray(new String[result.size()]);
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.putExtra(android.content.Intent.EXTRA_EMAIL,reciepients);
email.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
email.putExtra(android.content.Intent.EXTRA_TEXT, emailMessage);
email.setType("text/plain");
email.setType("message/rfc822");
Intent intent = Intent.createChooser(email, "Choose Email Client");
//context.start(Intent.createChooser(email, "Choose Email.."));
((Activity)context).startActivityForResult(intent, FinalVariables.SEND_EMAIL);
Run Code Online (Sandbox Code Playgroud)
onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case FinalVariables.SEND_EMAIL:
if(resultCode==Activity.RESULT_CANCELED){
showToast("Cancelled");
}
else if(resultCode==Activity.RESULT_OK){
showToast("Success");
}
break;
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
但这种方式总是让我取消,因为电子邮件客户端永远不会将RESULT设置为RESULT_OK.
那么我怎样才能满足我的要求呢.请建议.
谢谢