Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Windows display in activity

matutematute Member ✭✭

I need to hide the window of an activity in xamarin android. Try the Windows.NoDisplay themes but they ask you to specify the Finish () method in the OnCreate (), it's not what I want. Try to make the window transparent but with no flag I could interact with what is behind. Does anyone know something?

Best Answer

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Hi @matute , what do you mean by words the window of an activity? Is it a Dialog of an activity?

    Besides, I don't quite follow you about this words Try the Windows.NoDisplay themes but they ask you to specify the Finish () method in the OnCreate (), it's not what I want. Try to make the window transparent but with no flag I could interact with what is behind..
    Can you elaborate more on your question?

  • matutematute Member ✭✭

    Yeah sory, i wanted to NOT display the window/layout of an Activity (remember that an activity, even if you do not specify the layout, will open a blank window), I mean, like if it were a service for example (just that I needed it to be an activity because of its overwritable methods). So, after some research, i discovered that finishing the Activity in the OnCreate method (calling Finish(); before it end and specifying a theme like AppCompat.NoDisplay for AppCompatActivities) the problem was solved, BUT it you had some Intent that fires OnActivityResult before OnCreate(), then you got problems. Hence, i figured out to make my window/layout transparent, so...i didn´t have to worry about calling Finish() (I should not worry about the life cycle of the activity anymore), BUT you can't interact with the things behind your transparent window/layout. How i solved it?....very easy, adding to the Window/layout a flag named "NotTochable", that´s the trick.
    So if you want an activity with a transparent window and that the user can interact with what is behind it, there is your flag. Put it in the OnCreate method.
    Sory about my english, i am from Argentina!
    I hope I have been clear and helped whoever needs it, thanks in advance.

  • jezhjezh Member, Xamarin Team Xamurai

    Since you have put a transparent window/layout above your page, you couldn't interface with the things behind the transparent window/layout.

    i wanted to NOT display the window/layout of an Activity (remember that an activity, even if you do not specify the layout, will open a blank window), I mean, like if it were a service for example (just that I needed it to be an activity because of its overwritable methods).

    I don't quite understand what you said above. Since it were a service, it should run in the background and not have any UI.

    Why do you use an Activity? You say you need the overwritable methods of activity, while service also has a corresponding method, you can check the official document: https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/services/creating-a-service/bound-services#extend-the-service-class

    Besides,could you tell me exactly what features you want?

  • matutematute Member ✭✭

    i ´ve already solve it, i did just what i wanted. I'm just giving the solution to the problem I had. If you did not understand, I repeat more specifically:
    1) I needed to use an activity WITHOUT DEPLOYING LAYOUT. WITHOUT IT BEING A SERVICE ... I REPEAT .... AN ACTIVITY.
    2) CHOOSE A TRANSPARENT LAYOUT TO SIMULATE NO LAYOUT DEPLOYS
    3) ACHIEVE MY COMMITMENT BY USING FLAGS WHEN THE ACTIVITY IS CREATED, NOW THE USER CAN INTERACT WITH WHAT IS BEHIND.
    As simple as that, I can't be clearer. I hope you have understood, I do not need documentation or follow instructions, I was just sharing the knowledge I achieved for the rest of the people who cross the same path.
    Thank´s anyway

Sign In or Register to comment.