1

I am listening to a certain event (picture taken using the default camera app). When the picture is taken, my broadcast runs and it creates a Transparent activity with dialog.

The problem is that the activity has black background and it is not transparent (not seeing the pic taken by camera app). I used the TaskAffinity and still same issue? What should I do?

Broadcast:

public void onReceive(Context context, Intent intent) {


   Intent i = new Intent(context, DialogAct.class); 
   i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
   context.startActivity(i);

 }

Manifest:

<receiver
            android:name=".CameraEventReceiver" 
            android:enabled="true" >
            <intent-filter>
                <action android:name="android.hardware.action.NEW_PICTURE" />

                <data android:mimeType="image/*" />
            </intent-filter>
        </receiver>

<activity
            android:name=".DialogAct" android:theme="@style/Theme.D1NoTitleDim"
            android:launchMode="singleInstance"
            android:label="@string/app_name"
            android:taskAffinity="com.xxx.newaffinity.DialogAct" >
            <intent-filter>
                <action android:name="com.xxx.xx.DIALOGACT" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

style:

<style name="Theme.D1NoTitleDim" parent="android:style/Theme.Translucent">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">@android:color/transparent</item>
</style>

I have tried the style before and it works so the issue is not here. I don't know how to achieve the transparent activity..hhhheeeelp :(

Snake
  • 14,228
  • 27
  • 117
  • 250
  • Are you getting the 100% transparent background??? – Jagadesh Seeram Dec 17 '13 at 05:24
  • I am getting 0% transparency. Total black background – Snake Dec 17 '13 at 05:26
  • I doubt it is possible. The activity that leaves the screen goes through _onPause()_ _onStop()_. That activity would not draw itself after that. An alternative is to add a new view to FrameLayout. **Or** you can look at the sources and see how Dialog is implemented. They use something related to Window (e.g. http://stackoverflow.com/a/13962770/755804 ). – 18446744073709551615 Dec 17 '13 at 06:00

2 Answers2

1

you can use this code:

getWindow().setBackgroundDrawable(
                new ColorDrawable(Color.TRANSPARENT));
setContentView(R.layout.xml_editphoto);
dipali
  • 10,966
  • 5
  • 25
  • 51
0

You can try this style for Transparent Activity

<style name="Theme.Transparent" parent="android:Theme">#03afee
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:backgroundDimEnabled">false</item>
   </style>
Nitesh Tiwari
  • 4,742
  • 3
  • 28
  • 46
  • Didn't work. I tried it. But as I said the style I had before worked when your transition from activity to activity in my normal app flow. Just transaprency does not work from broadcast receiver to activity – Snake Dec 17 '13 at 05:41