I am using Scringo for implementing Group Chat within my Android App. Is there a way in which we can open a particular chatroom through code ? Right now, from the sample applications and API, I found only the below code.
Scringo.openChatRooms(MainActivity.this);
Please let me know how do I
Create a Chatroom programmatically
Open a particular Chatroom programmatically.
Right now Scringo SDK is not providing way to open a chatroom programmatically. They are having their own screens(Activity) to manage the many to many Chat functionality. They are yet to integrate the following features on their Android SDK.
1. Creating Chatrooms programmatically
2. Joining/Opening Chatrooms programmatically
Source: I got a response from their Support Team. They claim that this feature is available for their IOS sdk. I am not sure.
This code solved my problem :
MainActivity.java
public class MainActivity extends Activity {
private Scringo scringo;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
scringo = new Scringo(this);
...
findViewById(R.id.openChatRoomButton).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
Scringo.openChatRooms(MainActivity.this);
}
});
...
}
main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
...
<Button
android:id="#+id/openChatRoomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:text="#string/open_inbox_button_text" />
</RelativeLayout>
Related
I have been over the documentation here:
https://developer.android.com/guide/topics/ui/settings
The above page talks about creating a settings UI in your app, and shows using an XML file (that it doesn't tell you where to put by the way).
I do not want to add a settings UI in my app. I just want a setting to appear in android settings app under Apps when you pick my app from that list, it already has a section called "App settings". I want to add a setting for my app here, and be able to read it from my app. (Would be a bonus to be able to write to it from my app as well.)
Is this possible to do this and if so, can someone point me to an example.
Thanks for your time.
If you want to achieve that, you should add following nuget package firstly.
Xamarin.Android.Support.v7.Preference
Then create xml folder, Add the preferences.xml.
Here is code add preferences.xml for testing.
<PreferenceScreen
xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreferenceCompat
app:key="notifications"
app:title="Enable message notifications"/>
<Preference
app:key="feedback"
app:title="Send feedback"
app:summary="Report technical issues or suggest new features"/>
</PreferenceScreen>
Then create a class called MySettingsFragment.cs, PreferenceFragmentCompat comes from Android.Support.V7.Preferences, populator the preferences.xml by SetPreferencesFromResource method.
using Android.OS;
using Android.Runtime;
using Android.Support.V7.Preferences;
using Android.Views;
using Android.Widget;
namespace App32
{
public class MySettingsFragment : PreferenceFragmentCompat
{
public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
{
SetPreferencesFromResource(Resource.Xml.preferences, rootKey);
}
}
}
In the end, we can add a FrameLayout in your layout.xml
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/settings_container"/>
</RelativeLayout>
In the activity to use MySettingsFragment like Fragment's transaction.
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.settings_container,new MySettingsFragment()).Commit();
}
}
}
Here is running sceenshot.
I ended up going with Xamarin.Essentials: Preferences as this was the closest I could find to what I wanted and I didn't have to have a settings UI in the app.
https://learn.microsoft.com/en-us/xamarin/essentials/preferences?context=xamarin%2Fandroid&tabs=android
As I searched for the answer to my question I saw some solutions which didn't helped me.. So the problem is that in my xamarin android app I'm trying to create facebook authentication, so first move is to create facebook login button
FacebookLoginView.axml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/relativeLayout1">
<com.facebook.login.widget.LoginButton
android:id="#+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
It looks like this
FacebookLoginView.cs
[Activity(Label = "Facebook login")]
class FacebookLoginView : MvxActivity
{
private LoginButton loginButton;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
RequestWindowFeature(WindowFeatures.NoTitle);
//FacebookSdk.SdkInitialize(ApplicationContext);
SetContentView(Resource.Layout.FacebookLoginView);
}
}
When I run the code I'm getting this exception:
When I uncomment FacebookSdk.SdkInitialize(ApplicationContext); and run the app I'm getting this error:
So there are no info about the second error and I don't know how can I fix this... Could someone please explain me what I'm doing wrong?
UPDATE 1
I managed to update Xamarin.Facebook.Android from 4.16.1 to the latest version 4.24.0, but the errors are the same....
I am new to android development and I am working on an android project where I have to integrate QR scanner. So I thought I would integrate Zxing QR scanner and came across this library https://github.com/dm77/barcodescanner, Following the instructions provided I have successfully integrated and scanned a QR as well.
Now I want to customise the camera view. The problem is there is no documentation on how to get access to the camera layout. Since I am new I might be missing something.
I have read through many Zxing related threads but I din find any solution.
Any help will be greatly appreciated either by letting me know on how I can get access to the camera view or pointing me out to some articles. Once I know how then I can complete the rest.
I would be happy to provide any further information.
Thanks in advance.
Update:
public class QrScanActivity extends BaseActivity implements ZXingScannerView.ResultHandler {
private ZXingScannerView mScannerView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_scan);
// Programmatically initialize the scanner view
mScannerView = new ZXingScannerView(this);
// Set the scanner view as the content view
setContentView(mScannerView);
}
mScannerView is the view from the library. I want to get access to that view. I have a view called as activity_my_scan. I can add custom layout to that and use that but I don't know how to bypass the layout being used by the library.
Instead of just adding this lib as a jar using gradle's
compile 'me.dm7.barcodescanner:zxing:1.6.3'
you could clone the project from github or download a zip and uzip it and integrate to your project as a lib project. And then make any desired changes in its sources and its layouts.
ZXingScannerView extends BarcodeScannerView. You can access this by going to the declaration of ZXingScannerView (in Android Studio Ctrl+B).
public class ZXingScannerView extends BarcodeScannerView {
private MultiFormatReader mMultiFormatReader;
public static final List<BarcodeFormat> ALL_FORMATS = new ArrayList();
private List<BarcodeFormat> mFormats;
private ZXingScannerView.ResultHandler mResultHandler;
If you go the declaration of BarcodeScannerView, you'll notice a method called setupLayout() which formats the layout:
public void setupLayout() {
this.mPreview = new CameraPreview(this.getContext());
this.mViewFinderView = new ViewFinderView(this.getContext());
RelativeLayout relativeLayout = new RelativeLayout(this.getContext());
relativeLayout.setGravity(17);
relativeLayout.setBackgroundColor(-16777216);
relativeLayout.addView(this.mPreview);
this.addView(relativeLayout);
this.addView(this.mViewFinderView);
}
By going to the declaration of "CameraPreview" you'll be able to get more info for how the camera is laid out and you could maybe extend ZXingScannerView to edit the layout.
Hope this helps!
Cheers!
Well in your case i would try to include the layout into another layout, maybe it helps:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:background="#color/app_bg"
android:gravity="center_horizontal">
<include layout="#layout/titlebar"/>
<TextView android:layout_width=”match_parent”
android:layout_height="wrap_content"
android:text="#string/hello"
android:padding="10dp" />
...
</LinearLayout>
And of course there is information about that here ;)
I made a android app in that it has a listview with rss feeds .so I am trying to implement pull to refresh in my app for loading but I searched for a library I am getting link of [https://github.com/johannilsson/android-pulltorefresh] this .But I don't know How to integrate this library to my android app and I didn't find any jar related to this.please help me.
Recently, Google has implemented PullToRefreshView into its support v4 library. You can find at SwipeRefreshLayout
The implementation is very simple.
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_view"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}">
<ListView
android:id="#+id/list_view"
android:scrollbarStyle="outsideInset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v4.widget.SwipeRefreshLayout>
In your class, you can implement something like this.
mSwipeView.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
android.R.color.holo_red_light, android.R.color.holo_orange_light);
mSwipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override public void onRefresh() {
// Your action here
}
});
And cancel it by
mSwipeView.setRefreshing(false);
I am developing an Android Application. In this application, Logo bar is shown on all pages(Activities) or we can say it has header on all pages.
This Logo Bar have few icons like Home, Login, Notification, etc. and on Clicking on these icons corresponding navigation will perform.
for example if user is any where in application and click on home icon, he will navigate to the home page of application.
I am able to inflate logobar.XML into my All Activity by coding. but problem is i have to call onClickListener on all pages for all icons in Logo Bar.
This is not a good programming way.
How can i implement Logo Bar Activity in all other activity without repeating of code?
Is android have any Master Page concept as in .Net or tiles concept as in Struts?
Please guide me.
Edit: ok i got it. may be this answer will help you.
Try using Tab widget with tabactivity check this link for using fragment and tab http://developer.android.com/reference/android/app/TabActivity.html for android. i think for lower versions also we can use this. this si what the link says - "you can use the v4 support library which provides a version of the Fragment API that is compatible down to DONUT."
you have to create your masterLayout in xml and that you have to include it in your other
layouts in which you have to have it.
The solution was pretty easy.
You need to extends "Activity" Class,in onCreate function SetContentView to your base xml layout and also need to override setContentView in base Activity Class
For Example:
1.Create "base_layout.xml" with the below code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000"
android:padding="15dp" >
<LinearLayout android:orientation="horizontal" android:background="#000000"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:minHeight="50dp" android:paddingLeft="10dp">
<ImageView android:layout_width="wrap_content" android:id="#+id/ImageView01"
android:adjustViewBounds="true" android:layout_height="wrap_content"
android:scaleType="fitCenter" android:maxHeight="50dp" />
</LinearLayout>
<LinearLayout android:id="#+id/linBase"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</LinearLayout>
</LinearLayout>
2.Create "BaseActivity.java"
public class BaseActivity extends Activity {
ImageView image;
LinearLayout linBase;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.base_layout);
image = (ImageView)findViewById(R.id.ImageView01);
image.setImageResource(R.drawable.header);
linBase = (LinearLayout)findViewById(R.id.linBase);
}
#Override
public void setContentView(int id) {
LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(id, linBase);
}
}
and
public class SomeActivity extends BaseActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.some_layout);
//rest of code
}
}
The only thing I noticed so far was that when requesting a progress bar (requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) this needs to be done before calling super.onCreate. I think this is because nothing can be drawn yet before calling this function.
This worked great for me and hopefully you will find this useful in your own coding.
There is something like that, but only available on api 11+ (3.2 and Android 4.0.x Ice Cream Sandwich). Its called actionbar ( http://developer.android.com/reference/android/app/ActionBar.html).
I have done this using XML file.
I am just creating runtime view from XML file , and add it to the Activity layout.
I have created method for that
public static void setLoginview(Context ctx, RelativeLayout layout) {
LayoutInflater linflater = (LayoutInflater) ctx
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View myView = linflater.inflate(R.layout.loginheader, null);
layout.addView(myView);
try {
layout.getChildAt(0).setPadding(0, 50, 0, 0);
} catch (Exception e) {
}
}
ctx is the application contetx and layout is the layout in which i want to add that view.