81372018 |awsware Intemational - mobile app development
jawsware
international
mobile app development
Jawsware International
Like Page 17 likes
856.359.4685 | mobile@jawsware.com
SOURCE CODE SHARING
Interactive Overlay e mow dated: 18/2013
This project shows how to create a view that is overlaid on top of all other elements on the screen. It also
demonstrates how to allow the user to interact with the view.
To create an overlay view, when setting up the LayoutParams:
DON'T set the type to TYPE_SYSTEM_OVERLAY.
Instead set it to TYPE_PHONE.
Use the following flags:
FLAG_NOT_TOUCH_MODAL
FLAG_WATCH_OUTSIDE_TOUCH
FLAG_NOT_FOCUSABLE
‘Also make sure you add the SYSTEM_ALERT_WINDOW permission to the mainifest file.
This sample works by extending the two abstract classes as shown below.
OverlayView.java
package com. jawsware.core. shares
y+
Copyright 2211 jawsware international
itp nw jawsware.mobilcode_CverlayView! 4881372018 |awsware Intemational - mobile app development
Licensed under the Apache License, Version 2.0 (the "License'
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
eto: //amy, apache. org/Licenses/LICENSE-2.@
Unless required by applicable law on agreed to in writing, software
distributed under the License is distributed on an "AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
Limitations uncer the License.
”
import androsd.content .context;
‘import android. graphics.PixelFornat;
import android. view.Gravity;
import android. view.LayoutInflater;
linport android. view.Motiontvent;
iii
OverlayService.java
package com. jawsware. core. share;
|.
(Copyright 2011 jawsware international
Licensed under the Apache License, Version 2.8 (the “License");
lyou may not use this file except in compliance with the License.
Wvou may obtain 2 copy of the License at
http: //wan. apache. org/licenses/LICENSE-2.0
luniess required by applicable law or agreed to in writing, software
ldistributed under the License is distributed on an "AS TS” BASTS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or inplied.
Ise the License for the specific language governing permissions and
lLimitations under the License.
Is
import android.app.Notification;
linport android. app.Notificationtanager;
import android. app-Service;
iinport android.content..Intent;
linport android.os.TBinder;
SampleOverlayView.java
pacKage-sampres:j Ss a5
I+
(Copyright 2011 jawsware international
Licensed under the Apache License, Version 2.8 (the “License");
lyou may not use this file except in compliance with the License.
Wvou may obtain a copy of the License at
http: //imau.apache.org/Licenses/LICENSE-2.8
luniess required by applicable law or agreed to in writing, software
idistributed under the License is distributed on an "AS IS” BASTS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, e{ther express or implied.
Isee the License for the specific language governing permissions and
itp srw jawsware.mobilcode_CverlayViow!
2881372018 |awsware Intemational - mobile app development
Is
limport android. view.Gravity;
import android. view.Motionévents
import android.widget. TextView;
linport con.jawsware.core.share.OverlayService;
import con. jawsware core. share.OverlayView;
SampleOverlayService.java
‘instance. stopself();
y
goverride
protected Notification foregroundNotification(int notificationré) {
Notification notification;
notification = new Notification(R.drawable.ic launcher, getString(R.string. title notifica
notification. flags = notification.flags | Notification.FLAG_ONGOING_EVENT | Notification.
notification. setLatestEventInfo(this, getString(R.string.title notification), getString(R
return notification;
private PendingIntent notificationtntent() {
Intent intent = new Intent(this, SampleOverlayHideActivity class);
return pending;
PendingIntent pending = PendingIntent.getActivity(this, @, intent, PendingIntent..FLAG_UPO
jawsware international + 856.359.4685 + mobile@jawsware.com
Apps * Code
itp nw jawsware.mobilcode _CverlayView!
313