我想signalR在android应用程序中集成但没有运气.我一直在寻找各种链接,但没有一个提供有关实现的正确信息.
我有以下问题.
SignalR 集成必须在服务/意图服务中完成?我已经添加了三个库,即signalr android,signalr client和gson而无法理解的代码是如何工作的,没有适当的文档可以理解的代码.
提出了一些问题但没有太多信息
Android Studio中的SignalR 无法在Android中使用SignalR实现p2p聊天
如果有人对本机应用程序有信号经验,那对我来说会非常有帮助.
更新
public class SignalRService extends Service {
private static final String TAG = "Service";
private HubConnection mHubConnection;
private HubProxy mHubProxy;
private Handler mHandler; // to display Toast message
private final IBinder mBinder = new LocalBinder();
private SharedPreferences sp;
@Override
public void onCreate() {
super.onCreate();
Utility.showLog(TAG, "Service Created");
sp = getSharedPreferences(Utility.SHARED_PREFS, MODE_PRIVATE);
mHandler = new Handler(Looper.myLooper());
}
@Override …Run Code Online (Sandbox Code Playgroud) 有很多与之相关的问题,但没有一个能帮助我找到解决方案.
我正在尝试将所有联系人从设备同步到远程服务器,并且能够轻松完成,但是当更新/删除/插入(新联系人)等联系人发生更改时无法找到解决方案.
尝试使用ContentObserver但onChange()被多次调用.很难找到联系人更改数据.
public class ContactService extends Service {
private int mContactCount;
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
mContactCount = getContactCount();
Log.d("Contact Service", mContactCount + "");
this.getContentResolver().registerContentObserver(
ContactsContract.Contacts.CONTENT_URI, true, mObserver);
}
private int getContactCount() {
Cursor cursor = null;
try {
cursor = getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, null, null,
null);
if (cursor != null) {
return cursor.getCount();
} else {
return 0;
}
} catch (Exception ignore) { …Run Code Online (Sandbox Code Playgroud) 我试图保存片段状态,onSaveInstanceState但当我回到片段时,它总是重新加载而不是从上一个状态开始.
我调查了onCreateView,onActivityCreated它总是onSaveInstanceState为空.
public void navigateFragment(String tag, Fragment fragment,
boolean shouldAdd) {
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction ft = manager.beginTransaction();
if (shouldAdd)
mStacks.get(tag).push(fragment); // push fragment on stack
ft.replace(android.R.id.tabcontent, fragment);
if (shouldAdd)
ft.addToBackStack(tag);
ft.commit();
}
Run Code Online (Sandbox Code Playgroud)
由于我无法使用,backstack因为在标签中,堆栈没有用.任何帮助将受到高度赞赏.
我想设置navigation drawer使用NavigationView.项目不可见但是当我们点击空白区域时,特定项目点击代码正在执行.看起来物品看不见但可点击.
我试过玩背景颜色,但它似乎不起作用.
任何帮助,将不胜感激.
home.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White"
android:fitsSystemWindows="true"
tools:context=".Home.HomeActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar" />
<!-- Main Content -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/White">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White"
android:orientation="vertical"
android:weightSum="1">
<android.support.design.widget.NavigationView
android:id="@+id/NavigationView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="start"
android:layout_weight="1"
android:background="@color/White"
android:fitsSystemWindows="true"
android:scrollbars="none"
app:elevation="0dp"
app:headerLayout="@layout/navigation_header"
app:itemIconTint="@color/YellowOrange"
app:itemTextColor="@color/Black"
app:menu="@menu/nav_menu" />
<com.squawkinit.orionfreightelite.customview.CustomTextView
android:id="@+id/tvAppVersion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dp"
android:textColor="@color/Black"
android:textSize="14sp" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
nav_menu.xml(菜单) …
我正在努力创造tab layout with fragments.当我在项目上添加另一个片段时,它应该在它上面显示另一个片段.我无法达到目标.片段刚好超过现有片段,但片段内容都可见.请不要将链接抛向任何开发者页面以获得解释.
这是我的代码
home_activity.xml
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.example.tabsfragment.School_Fragment" >
</fragment>
<fragment
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.example.tabsfragment.Sports_Fragment" >
</fragment>
</FrameLayout>
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)
Home_Activity.java
public class Home_Activity extends FragmentActivity {
TabHost mHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_activity);
mHost = (TabHost) findViewById(android.R.id.tabhost);
mHost.setup();
TabSpec schoolSpec = mHost.newTabSpec("School").setIndicator("School")
.setContent(R.id.tab1);
mHost.addTab(schoolSpec);
TabSpec sportSpec = mHost.newTabSpec("Sports").setIndicator("Sportss")
.setContent(R.id.tab2); …Run Code Online (Sandbox Code Playgroud) 我有两个fragments,Fragment A而且Fragment B.Fragment A列出所有产品并Fragment B显示有关产品及其图像的详细信息.
Fragment A从Web服务调用Fragment B和Fragment B提取数据并设置为ViewPager使用Adapter.最初它显示正确的图像,但此后它总是具有相同的图像.
如果我们adapter.notifyDataSetChanged()从片段B中的任何点击事件中触发,那么它可以完美地工作,但只要片段B可见,我们就必须立即显示
请看代码.
public class ImageAdapter extends FragmentStatePagerAdapter {
private List<String> pImageURL;
public ImageAdapter(FragmentManager fm, List<String> imageURL) {
super(fm);
// TODO Auto-generated constructor stub
pImageURL = imageURL;
Utility.showLog("PagerAdapter URL", pImageURL.toString());
}
@Override
public Fragment getItem(int position) {
// TODO Auto-generated method stub
String imageURL = pImageURL.get(position);
PImageFragment imageFragment = (PImageFragment) PImageFragment.getInstance(); …Run Code Online (Sandbox Code Playgroud) 我知道SO有关问题的帖子有各种各样的问题,但没有一个问题能为我提供解决方案.我有4个标签fragment activity,每个标签都有自己的标签fragment.我要进入另一个fragment里面.当我切换到标签时,它有时会重叠并且两者都可见.
这是代码(xml):
<Button
android:id="@+id/checkBal"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:clickable="false"
android:gravity="left|center_vertical"
android:typeface="serif" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:background="@color/green" />
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
</android.support.v4.app.FragmentTabHost>
Run Code Online (Sandbox Code Playgroud)
public class Tab_Activity extends FragmentActivity {
FragmentTabHost mHost;
Button balance;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
balance = (Button) findViewById(R.id.checkBal);
mHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
mHost.addTab(mHost.newTabSpec("Home").setIndicator("Home"), …Run Code Online (Sandbox Code Playgroud) 我试图打开基于notification点击的不同视图控制器,但是当push notification它被接收时它会自动在后台运行控制器代码,所以当我通过应用程序图标/通知打开应用程序时notification centre,view controller立即加载,但是当收到多个通知时,它会加载第一个通知控制器无论采用哪种通知.
假设我已收到标题为"晚上","早晨"和"夜晚"的通知,当点击"晚上"通知时它应打开"晚间视图控制器",但当我回去加载时它会加载"夜视控制器" "早晨视图控制器",最后加载"晚视图控制器".在通知发出之前,我在主控制器上,然后我将应用程序移至后台.
当我点击"早晨"时,notification它现在什么都不做.
之前我尝试过使用addObserver,但结果是一样的,所以我转到app delegate.
这是app委托代码
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIApplication sharedApplication]setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
// Override point for customization after application launch.
// Register for Push Notitications, if running iOS 8 or More
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
// Register …Run Code Online (Sandbox Code Playgroud) notifications objective-c viewcontroller ios notificationcenter
我想只显示从url下载后加载到缓存中的那些图像 Universal Image Loader
例
我有15个URL来下载图像和显示ViewPager,但其中只有5个被下载,我关闭了应用程序..现在我没有任何互联网连接从网络获取所有其他图像,但应用程序将只显示5图像和剩余页面将为空白..
是否有可能只获得那些图像的列表cache Memory?
我们如何限制ViewPager其他空白页?
我已成功实施Universal Image Loader,但却陷入了这些问题.
任何想法/建议/样品将不胜感激..
谢谢
我试图在这里得到答案,但没有得到任何完美的答案.我想显示在上下文菜单中onItemLongClick,但没有成功,因为我同时使用onItemClick和onItemLongClick
我正在onItemClick用来开始一项新的活动,但两者都没有成功.
这是代码
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.all_contacts);
contactList = new ArrayList<HashMap<String,String>>();
new LoadAllContacts().execute();
registerForContextMenu(getListView());
ListView listView = getListView();
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int postion, long id) {
registerForContextMenu( view );
openContextMenu( view );
return true;
}
});
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int postion, long id) {
Intent intent = new Intent(AllContactsActivity.this, editContactActivity.class);
}
});
}
@Override
protected …Run Code Online (Sandbox Code Playgroud) android ×9
fragment ×2
.net ×1
asp.net-mvc ×1
c# ×1
ios ×1
objective-c ×1
signalr ×1
sync ×1
tabs ×1