Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ add permissionCheck with Android >=23
+ set Target Version to 23 + remove depricated Notification implementation
- Loading branch information
Showing
6 changed files
with
545 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ | |
# project structure. | ||
|
||
# Project target. | ||
target=android-21 | ||
target=android-23 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2016 team-cachebox.de | ||
* | ||
* Licensed under the : GNU General Public License (GPL); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.gnu.org/licenses/gpl.html | ||
* | ||
* Unless required by applicable law or 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 under the License. | ||
*/ | ||
package de.cachebox_test; | ||
|
||
import java.util.ArrayList; | ||
|
||
import android.app.Activity; | ||
import android.content.pm.PackageManager; | ||
import android.support.v4.app.ActivityCompat; | ||
import android.support.v4.content.ContextCompat; | ||
|
||
/** | ||
* Created by Longri on 11.05.2016. | ||
*/ | ||
public class PermissionCheck { | ||
|
||
public static final int MY_PERMISSIONS_REQUEST = 11052016; | ||
static final String WAKE_LOCK = "android.permission.WAKE_LOCK"; | ||
static final String INTERNET = "android.permission.INTERNET"; | ||
static final String ACCESS_NETWORK_STATE = "android.permission.ACCESS_NETWORK_STATE"; | ||
static final String RECORD_AUDIO = "android.permission.RECORD_AUDIO"; | ||
static final String CAMERA = "android.permission.CAMERA"; | ||
static final String VIBRATE = "android.permission.VIBRATE"; | ||
static final String WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE"; | ||
static final String READ_EXTERNAL_STORAGE = "android.permission.READ_EXTERNAL_STORAGE"; | ||
|
||
static final String[] NEEDED_PERMISSIONS = new String[] { WAKE_LOCK, INTERNET, ACCESS_NETWORK_STATE, RECORD_AUDIO, CAMERA, VIBRATE, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE }; | ||
|
||
public static void checkNeededPermissions(Activity context) { | ||
ArrayList<String> DENIED_List = new ArrayList<String>(); | ||
|
||
for (String permission : NEEDED_PERMISSIONS) { | ||
if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) { | ||
DENIED_List.add(permission); | ||
} | ||
} | ||
|
||
if (!DENIED_List.isEmpty()) { | ||
String[] ar = DENIED_List.toArray(new String[DENIED_List.size()]); | ||
ActivityCompat.requestPermissions(context, ar, MY_PERMISSIONS_REQUEST); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.