以下是更新appwidget的静态方法:
public static void updateAppWidget(Context context, int id, WALL_POST_DETAILS post){
try{
System.out.println("In updateAppWidget==>"+id);
AppWidgetManager mngr=AppWidgetManager.getInstance(context);
String diff=diff(post.created_time.trim());
RemoteViews views=new RemoteViews(context.getPackageName(),R.layout.widget_layout);
PendingIntent pending=PendingIntent.getActivity(context, 0, new Intent(context,ShareDialogActivity.class), 0);
views.setOnClickPendingIntent(R.id.TextView01, pending);
views.setOnClickPendingIntent(R.id.Button03, pending);
views.setTextViewText(R.id.actor_name, post.actor_name);
views.setTextViewText(R.id.actor_message, post.message);
views.setImageViewBitmap(R.id.actor_photo, post.image);
views.setTextViewText(R.id.created_time, diff);
if(post.no_of_comments>0){
views.setViewVisibility(R.id.comments_image, View.VISIBLE);
views.setViewVisibility(R.id.comment_word, View.VISIBLE);
views.setTextViewText(R.id.no_of_comments, String.valueOf(post.no_of_comments));
views.setViewVisibility(R.id.no_of_comments, View.VISIBLE);
System.out.println("No. of Comments==>"+post.no_of_comments);
}else{
views.setViewVisibility(R.id.comments_image, View.INVISIBLE);
views.setViewVisibility(R.id.comment_word, View.INVISIBLE);
views.setTextViewText(R.id.no_of_comments, String.valueOf(""));
views.setViewVisibility(R.id.no_of_comments, View.INVISIBLE);
}
if(post.no_of_likes>0){
views.setViewVisibility(R.id.likes_image, View.VISIBLE);
views.setViewVisibility(R.id.likes_word, View.VISIBLE);
views.setTextViewText(R.id.no_of_likes, String.valueOf(post.no_of_likes));
views.setViewVisibility(R.id.no_of_likes, View.VISIBLE);
}else{
views.setViewVisibility(R.id.likes_image, View.INVISIBLE);
views.setViewVisibility(R.id.likes_word, View.INVISIBLE);
views.setTextViewText(R.id.no_of_likes, String.valueOf(""));
views.setViewVisibility(R.id.no_of_likes, View.INVISIBLE);
}
Intent …Run Code Online (Sandbox Code Playgroud) 我想知道我是否可以整合paypal而不使用paypal库为android.(可能正在使用webview)?
如果是,是否有任何教程可以了解该过程?
提前致谢.
我正在尝试使用改造库在Android中发送Mailgun POST /消息API请求.
以下是改装要求:
HTTP POST https:// api:key-xxx/v3/sandboxxxx/messages
缓存控制:无缓存
内容类型:application/x-www-form-urlencoded
内容长度:148
从=兴奋+用户+%3Cmailgun%40sandboxxxxmailgun.org%3E及为= vir.jain%40gmail.com&主题=您好与文本=测试+迷死
响应:HTTP 401 https:// api:key-xxx/v3/sandboxxxx.mailgun.org/messages(1966ms)
服务器:nginx/1.7.
9日期:星期一,2015年6月15日10:00:37 GMT
内容类型:为text/html; charset = utf-8
Content-Length:9
连接:keep-alive
WWW-Authenticate:Basic realm ="MG API"
OkHttp-Selected-Protocol:http/1.1
OkHttp-Sent-Millis:1434362440805
OkHttp-Received-Millis:1434362441086
Forbidden
当我在Postman上尝试同样的请求时,它完美地工作并且电子邮件被正确发送.但是当使用Android的改装库发送时,使用Forbidden失败了.
我的Retrofit API:@FormUrlEncoded @POST("/ messages")public void sendEmail(@Field("from")String from,@ Field("to")String to,@ Field("subject")String subject,@ Field ("text")String text,RestCallback objectRestCallback);
基本URL为: https:// api:key-xxx/v3/sandboxxxsandboxxxx.mailgun.org
一切都是表格URL编码.但我真的不确定出了什么问题.任何人都可以帮我解决上述API的错误吗?
谢谢Mahavir
我可以像这样构建字符串:
String str = "Phone number %s just texted about property %s";
String.format(str, "(714) 321-2620", "690 Warwick Avenue (679871)");
//Output: Phone number (714) 321-2620 just texted about property 690 Warwick Avenue (679871)
Run Code Online (Sandbox Code Playgroud)
我想要实现的是与此相反.输入将跟随字符串
电话号码(714)321-2620只是发短信给690 Warwick Avenue(679871)
我想从输入中检索" (714)321-2620 "和" 690 Warwick Avenue(679871) "
任何人都可以给指针,如何在Java或Android中实现这一点?
先感谢您.